Skip to content

[TS 2] React Component/PureComponent constructor super accept rest pa… - #11612

Merged
mhegazy merged 1 commit into
DefinitelyTyped:types-2.0from
beckend:linken
Oct 3, 2016
Merged

mhegazy merged 1 commit into
DefinitelyTyped:types-2.0from
beckend:linken

Conversation

@beckend

@beckend beckend commented Sep 29, 2016 •

Copy link
Copy Markdown
Contributor

This PR successfully passes spread operator to super calls on React.Component and React.PureComponent and fixes 11472.

I was unable to infer types on the spread array, but it seems that it's not possible yet.
Even so, when you call super with spread operator, you don't intend to use the props or context anyways.

It was not my intention to cleanup the white spaces in react/react-tests.ts since my editor auto cleans white spaces. But it is harmless.

@vvakame vvakame added the @types label Sep 30, 2016
@mhegazy
mhegazy merged commit 5fe46ff into DefinitelyTyped:types-2.0 Oct 3, 2016
@beckend
beckend deleted the linken branch October 4, 2016 07:23
@jwbay

jwbay commented Jan 23, 2017

Copy link
Copy Markdown
Contributor

Unfortunately this PR broke type inference for props for anything that uses ComponentClass<P>. Enzyme, a test library for React components, uses this extensively and props are not being type checked; everything is 'any'. I traced it back to this PR. Removing the spread constructor fixes the problem.

Moving the narrower definition first did not fix the problem, though it seems like it should. @Andy-MS @mhegazy could it be a TS issue that the narrower constructor doesn't take precedence and light up inference sites? Or is TS expected to throw its hands up if it sees (...args: any)?

@mhegazy

mhegazy commented Jan 23, 2017

Copy link
Copy Markdown
Contributor

I see. sorry did not catch that earlier. Please send a PR with the fix and i will merge it.

jwbay added a commit to jwbay/DefinitelyTyped that referenced this pull request Jan 24, 2017
@jwbay

jwbay commented Jan 24, 2017

Copy link
Copy Markdown
Contributor

Sure, thanks @mhegazy. PR is #14202

DanielRosenwasser added a commit that referenced this pull request Jan 25, 2017
React - Fix type inference for props. Reverts 80e4d8b/#11612. Fixes #14176
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants