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

[react-redux] Correctly infer prop types from wrapped component #28189

Merged

Conversation

apapirovski
Copy link
Contributor

@apapirovski apapirovski commented Aug 17, 2018

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).
  • Provide a URL to documentation or source code which provides context for the suggested changes: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html

This makes sure the inferred props include the defaultProps and propTypes resolutions by using JSX.LibraryManagedAttributes. I don't know how people feel about using JSX.LibraryManagedAttributes here directly but it feels better than rewriting the same thing from scratch...

This fixes #27959

@typescript-bot typescript-bot added the Popular package This PR affects a popular package (as counted by NPM download counts). label Aug 17, 2018
@typescript-bot
Copy link
Contributor

typescript-bot commented Aug 17, 2018

@apapirovski Thank you for submitting this PR!

🔔 @tkqubo @thasner @kenzierocks @clayne11 @tansongyang @NicholasBoll @mDibyo @pdeva @Kallikrein @val1984 @jrakotoharisoa - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Aug 23, 2018
@typescript-bot
Copy link
Contributor

typescript-bot commented Aug 23, 2018

A definition owner has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped!

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Aug 24, 2018

🔔 @tkqubo @thasner @kenzierocks @clayne11 @tansongyang @NicholasBoll @mDibyo @pdeva @Kallikrein @val1984 @jrakotoharisoa can you take a look please?

<ConnectedComponent fn={() => {}} />

const ConnectedComponent2 = connect<MapStateProps, void, OwnProps>(mapStateToProps)(Component);
<ConnectedComponent fn={() => {}} />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be <ConnectedComponent2 fn={() => {}} />?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Will fix that.

@typescript-bot typescript-bot removed the Unmerged The author did not merge the PR when it was ready. label Aug 30, 2018
@apapirovski
Copy link
Contributor Author

@DanielRosenwasser Looks like the bot removed the Merge: YSYL label accidentally. Any chance it could be re-added and/or this PR reviewed? Thanks in advance!

@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Sep 4, 2018
@typescript-bot typescript-bot removed the Unmerged The author did not merge the PR when it was ready. label Sep 7, 2018
@apapirovski
Copy link
Contributor Author

@DanielRosenwasser @tkqubo @thasner @kenzierocks @clayne11 @tansongyang @NicholasBoll @mDibyo @pdeva @Kallikrein @val1984 @jrakotoharisoa Wondering if there's any chance I could get this reviewed? It's been a little while now. Thanks in advance!

Copy link
Contributor

@octylFractal octylFractal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, except for the comment on Matching.

* a property P will be present if:
* - it is present in DecorationTargetProps
* - it is present in InjectedProps[P] and can satisfy DecorationTargetProps[P]
* or it is not present in InjectedProps[P]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused by this statement, it effectively says that P will be present if it is not present in InjectedProps?
This doesn't appear to match what the code does. Could this be cleared up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is not quite correct anymore for the recently updated version. Updating right now.

types/react-redux/index.d.ts Show resolved Hide resolved
@typescript-bot typescript-bot added Revision needed This PR needs code changes before it can be merged. and removed Awaiting reviewer feedback labels Sep 11, 2018
@typescript-bot
Copy link
Contributor

@apapirovski One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. Thank you!

@apapirovski
Copy link
Contributor Author

@kenzierocks I've updated the comment.

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Sep 12, 2018
@typescript-bot
Copy link
Contributor

typescript-bot commented Sep 12, 2018

@apapirovski The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@apapirovski
Copy link
Contributor Author

apapirovski commented Sep 12, 2018

I don't think the test is related to this PR :| See #28759

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Sep 12, 2018
Make sure the inferred props include the defaultProps and propTypes
resolutions by using JSX.LibraryManagedAttributes.
@typescript-bot typescript-bot added Revision needed This PR needs code changes before it can be merged. and removed The Travis CI build failed labels Sep 12, 2018
@typescript-bot
Copy link
Contributor

🔔 @kenzierocks - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate?

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Merge:Express labels Sep 12, 2018
@apapirovski
Copy link
Contributor Author

@kenzierocks Any chance you have the ability to add/remove labels? This has the "revision needed" which makes it impossible to merge.

Otherwise, @DanielRosenwasser? Any chance you can remove the label?

@octylFractal
Copy link
Contributor

I can't remove labels as a Contributor. You might try pushing again to re-run Travis, or if the failure is related to that PR, rebase off of master to incorporate the fix for it.

@apapirovski
Copy link
Contributor Author

apapirovski commented Sep 13, 2018

@kenzierocks Already reran Travis. I think the bot just has a bug around the "revision needed" label. Happened to me in another PR here a while ago. I guess we wait...

@OliverJAsh
Copy link
Contributor

This PR has caused a few new bugs. Please can someone advise? We're not sure what the intention of Matching is: #31363 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Owner Approved A listed owner of this package signed off on the pull request. Popular package This PR affects a popular package (as counted by NPM download counts). Revision needed This PR needs code changes before it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[@types/react-redux] defaultProps and Typescript 3.0
9 participants