Choice 1: Verify for null
:
<Modal
open={open ?? false}
onClose={onClose}
disableEscapeKeyDown={disableEscapeKeyDown === null ? undefined : disableEscapeKeyDown}
>
Alternatively, you can utilize ??
:
disableEscapeKeyDown ?? undefined
Choice 2: Exclude & intersect with accurate type:
export default function ModalWindow({
disableEscapeKeyDown = false,
}: Omit<ModalProps, "disableEscapeKeyDown"> & { disableEscapeKeyDown?: boolean }) {
Choice 3: Modify the definition of ModalProps
:
type ModalProps = PropTypes.InferProps<Omit<typeof propTypes, "disableEscapeKeyDown">> & { disableEscapeKeyDown?: boolean };
Choice 4: Disregard TypeScript:
<Modal
open={open ?? false}
onClose={onClose}
//@ts-ignore
disableEscapeKeyDown={disableEscapeKeyDown}
>
Regrettably, it seems impossible to "overwrite" or alter how PropTypes.InferProps
functions - even my attempts to redefine Requireable<T>
and Validator<T>
were unsuccessful. Therefore, the next best solution is to patch the outcomes of the type on your own.
Interactive Playground displaying all choices