We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript Version: 3.4.0-dev.20190131 (I spot checked versions since 3.0.1, all had this issue
Search Terms: intersection extra properties
Code
type Problematic = { one?: string } & { nested?: { two?: string } } function problem(input: Problematic) {} // nested containing bad property unexpectedly doesn't cause error problem({ nested: { two: 'hello', bad: 123 } })
Expected behavior: bad: 123 should cause an extra properties error.
bad: 123
Actual behavior: bad: 123 does not cause the extra properties error.
Playground Link: expanded examples
Related Issues: #28642
For anyone tripped up by this, there's a convenient work-around:
type Merge<T extends object> = { [K in keyof T]: T[K] }; type Problematic = { one?: string } & { nested?: { two?: string } } function problemGone(input: Merge<Problematic>) {} // works as expected problemGone({ nested: { two: 'hello', bad: 123 } })
The text was updated successfully, but these errors were encountered:
Duplicate of #13813
Sorry, something went wrong.
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
TypeScript Version: 3.4.0-dev.20190131 (I spot checked versions since 3.0.1, all had this issue
Search Terms: intersection extra properties
Code
Expected behavior:
bad: 123
should cause an extra properties error.Actual behavior:
bad: 123
does not cause the extra properties error.Playground Link: expanded examples
Related Issues: #28642
For anyone tripped up by this, there's a convenient work-around:
The text was updated successfully, but these errors were encountered: