Skip to content
New issue

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

Excess property checking on nested objects doesn't work in JSX as of TS 3.2 #28926

Closed
pelotom opened this issue Dec 9, 2018 · 2 comments
Closed
Labels
Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter
Milestone

Comments

@pelotom
Copy link

pelotom commented Dec 9, 2018

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.

@weswigham weswigham added Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter labels Dec 10, 2018
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 14, 2019
@christianalfoni
Copy link

christianalfoni commented May 20, 2019

After playing around with this for ages I got to the same conclusion, here shown in a Codesandbox: https://codesandbox.io/s/sleepy-moon-dqzl7

The funny thing is that the type error appears on the first property added to the object, but as soon as you have one valid property, all of them becomes valid.

Is this issue still considered a bug, now in the backlog?

@jakebailey
Copy link
Member

This one was fixed by #30853 but was missed in the list of issues it closed (but the PR does explicitly call out JSX excess property checking).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter
Projects
None yet
Development

No branches or pull requests

5 participants