You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeModalProps={excludedProp: ()=>void;someProp: ()=>void;[key: string]: unknown;}functionComponent(props: Omit<ModalProps,"excludedProp">){console.log(props.excludedProp());// Object is type of 'unknown'. This is ok.console.log(props.someProp())// Object is type of 'unknown'. This is unexpected.}
Workaround:
typeModalProps={excludedProp: ()=>void;someProp: ()=>void;[key: string]: unknown;}declarevar{ excludedProp, ...Omit_ModalProps_excludedProp}: ModalProps;functionComponent(props: typeofOmit_ModalProps_excludedProp){console.log(props.excludedProp());// Object is type of 'unknown'console.log(props.someProp());// works!}
Also, this works:
typeModalProps={excludedProp: ()=>void;someProp: ()=>void;}functionComponent(props: Omit<ModalProps,"excludedProp">){console.log(props.excludedProp());// Object is type of 'unknown'console.log(props.someProp())// works!}
Bug Report
⏯ Playground Link
Playground link with relevant code
💻 Code
Workaround:
Also, this works:
🙁 Actual behavior
In the first example the
props.someProp
isunknown
.🙂 Expected behavior
In the first example the
props.someProp
is() => void
.The text was updated successfully, but these errors were encountered: