Closed
Description
Bug Report
⏯ Playground Link
Playground link with relevant code
💻 Code
type ModalProps = {
excludedProp: () => void;
someProp: () => void;
[key: string]: unknown;
}
function Component(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:
type ModalProps = {
excludedProp: () => void;
someProp: () => void;
[key: string]: unknown;
}
declare var { excludedProp, ...Omit_ModalProps_excludedProp }: ModalProps;
function Component(props: typeof Omit_ModalProps_excludedProp) {
console.log(props.excludedProp()); // Object is type of 'unknown'
console.log(props.someProp()); // works!
}
Also, this works:
type ModalProps = {
excludedProp: () => void;
someProp: () => void;
}
function Component(props: Omit<ModalProps, "excludedProp">) {
console.log(props.excludedProp()); // Object is type of 'unknown'
console.log(props.someProp()) // works!
}
type ModalProps = {
someProp: () => void;
[key: string]: unknown;
}
function Component(props: ModalProps) {
console.log(props.someProp()) // works!
}
🙁 Actual behavior
In the first example the props.someProp
is unknown
.
🙂 Expected behavior
In the first example the props.someProp
is () => void
.
Metadata
Metadata
Assignees
Labels
No labels