Closed
Description
TypeScript Version: 3.2.2
Search Terms:
excess property jsx
Code
function Foo(props: { x: { foo: number } }) {
return null;
}
Foo({ x: { foo: 42, bar: 'hello' } }); // <-- correctly has error
<Foo x={{ foo: 42, bar: 'hello' }} />; // <-- incorrectly has no error
Expected behavior:
Both of the last 2 lines should exhibit an excess property error.
Actual behavior:
Only the first line does.
Related Issues:
It's also the case that
React.createElement(Foo, { x: { foo: 42, bar: 'hello' } });
fails to produce the error, however by tweaking the type of createElement
in @types/react
I'm able to fix that. So #14729 seems related, in that, if the JSX type checking were based on createElement
's type, this issue could be fixed by fixing @types/react
.