-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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] useSelector can infer its return type with shallowEqual #41540
Conversation
@kazuma1989 Thank you for submitting this PR! 🔔 @tkqubo @kenzierocks @clayne11 @tansongyang @NicholasBoll @mDibyo @Kallikrein @val1984 @jrakotoharisoa @apapirovski @surgeboris @soerenbf @MrWolfZ @DylanVann @Lazyuki - please review this PR in the next few days. Be sure to explicitly select If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead. |
👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings. Let’s review the numbers, shall we? Comparison details 📊
It looks like nothing changed too much. I won’t post performance data again unless it gets worse. |
@kazuma1989 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! |
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! |
@@ -1358,6 +1358,8 @@ function testUseSelector() { | |||
}); | |||
|
|||
useSelector(selector, shallowEqual); | |||
const inferredTypeIsNotString: string = useSelector(selector, shallowEqual); // $ExpectError | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add another test with a correctly inferred type just to be sure?
🔔 @Lazyuki - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate? |
Congratulations on your first DefinitelyTyped contribution! |
I just published |
Hi. I have an issue with a combination of
useSelector
andshallowEqual
(described below). I'd like to fix the issue!The return type of
useSelector
is perfectly inferred:But with
shallowEqual
, the return type is not inferred so it gets to beany
:A minimal repro is here: https://github.com/kazuma1989/repro-shallowEqual-missing-types
@dt-bot
Please fill in this template.
npm test
.)npm run lint package-name
(ortsc
if notslint.json
is present).If changing an existing definition:
If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.If you are making substantial changes, consider adding atslint.json
containing{ "extends": "dtslint/dt.json" }
. If for reason the any rule need to be disabled, disable it for that line using// tslint:disable-next-line [ruleName]
and not for whole package so that the need for disabling can be reviewed.