-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScript
Milestone
Description
Bug Report
π Search Terms
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about excess property checking
β― Playground Link
Playground link with relevant code
π» Code
type Props = { foo: string };
type Demo = {
props: Props;
} & {
props: Props;
};
type Collection = {
demo: Demo;
} & {
demo: Demo;
};
const t1: Collection = {
demo: {
props: {
foo: 'foo',
bar: 1, // expected error due to excess prop, but got none β
},
},
};If we remove one of the intersections, excess property checks kick in again.
This is clearly a contrived example however I have reduced it from a much more complicated example where we do actually need to use intersections in a similar way. I can elaborate if needed.
I have been able to workaround the issue using this Compact helper:
type Compact<A> = A extends Function ? A : { [K in keyof A]: A[K] } & {};
type Collection = Compact<{
demo: Demo;
} & {
demo: Demo;
}>;π Actual behavior
See comment in code above.
π Expected behavior
See comment in code above.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript