-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Fix react-router hooks test #45780
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
Fix react-router hooks test #45780
Conversation
microsoft/TypeScript#39081, which ships in Typescript 4.0, stops using binding patterns as contextual types for return type inference. react-router's `useParams` relied on this to fill in an object with `any`s in case a binding pattern was used but no type argument was provided. This no longer works. This fix just adds a type argument to the tests. For two other, more complete fixes, see microsoft/TypeScript#39081 (comment) Briefly, the options are (1) go back to returning `any`-filled object types or (2) tries to default to `string`. The second fix is probably the right one, but it may hurt compilation/IDE performance, so I'll leave it to the package owners to decide whether to make that change.
|
@sandersn Thank you for submitting this PR! Code ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 45780,
"author": "sandersn",
"owners": [
"sergey-buturlakin",
"mrk21",
"vasek17",
"ngbrown",
"awendland",
"KostyaEsmukov",
"johnnyreilly",
"LKay",
"DovydasNavickas",
"huy-nguyen",
"grmiade",
"DaIgeb",
"egorshulga",
"rraina",
"t49tran",
"8enSmith",
"wezleytsai",
"eps1lon",
"HipsterBrown",
"pawfa"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "aade5f0",
"headCommitOid": "aade5f07820376d894e5d5a1f94fc4fda03889b4",
"mergeIsRequested": true,
"stalenessInDays": 0,
"lastCommitDate": "2020-06-29T16:51:07.000Z",
"lastCommentDate": "2020-06-29T20:41:06.000Z",
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45780/files",
"hasMergeConflict": false,
"authorIsOwner": false,
"isFirstContribution": false,
"popularityLevel": "Critical",
"anyPackageIsNew": false,
"packages": [
"react-router"
],
"files": [
{
"filePath": "types/react-router/test/hooks.tsx",
"kind": "test",
"package": "react-router"
}
],
"hasDismissedReview": false,
"ciResult": "pass",
"lastReviewDate": "2020-06-29T20:12:10.000Z",
"reviewersWithStaleReviews": [],
"approvalFlags": 4,
"isChangesRequested": false
} |
|
🔔 @sergey-buturlakin @mrk21 @vasek17 @ngbrown @awendland @KostyaEsmukov @johnnyreilly @LKay @DovydasNavickas @huy-nguyen @Grmiade @DaIgeb @egorshulga @rraina @t49tran @8enSmith @wezleytsai @eps1lon @HipsterBrown @pawfa - please review this PR in the next few days. Be sure to explicitly select |
|
👋 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. |
johnnyreilly
left a comment
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.
Thanks for the details!
|
@sandersn Everything looks good here. Great job! I am ready to merge this PR on your behalf. If you'd like that to happen, please post a comment saying:
and I'll merge this PR almost instantly. Thanks for helping out! ❤️ |
|
Ready to merge |
…ersn microsoft/TypeScript#39081, which ships in Typescript 4.0, stops using binding patterns as contextual types for return type inference. react-router's `useParams` relied on this to fill in an object with `any`s in case a binding pattern was used but no type argument was provided. This no longer works. This fix just adds a type argument to the tests. For two other, more complete fixes, see microsoft/TypeScript#39081 (comment) Briefly, the options are (1) go back to returning `any`-filled object types or (2) tries to default to `string`. The second fix is probably the right one, but it may hurt compilation/IDE performance, so I'll leave it to the package owners to decide whether to make that change.
…ersn microsoft/TypeScript#39081, which ships in Typescript 4.0, stops using binding patterns as contextual types for return type inference. react-router's `useParams` relied on this to fill in an object with `any`s in case a binding pattern was used but no type argument was provided. This no longer works. This fix just adds a type argument to the tests. For two other, more complete fixes, see microsoft/TypeScript#39081 (comment) Briefly, the options are (1) go back to returning `any`-filled object types or (2) tries to default to `string`. The second fix is probably the right one, but it may hurt compilation/IDE performance, so I'll leave it to the package owners to decide whether to make that change.
microsoft/TypeScript#39081, which ships in Typescript 4.0, stops using binding patterns as contextual types for return type inference. react-router's
useParamsrelied on this to fill in an object withanys in case a binding pattern was used but no type argument was provided. This no longer works in 4.0.This fix just adds a type argument to the tests to reflect what users of TS 4.0 will have to do to use react-router.
For two other, more complete fixes, see
microsoft/TypeScript#39081 (comment)
Briefly, the options are (1) go back to returning
any-filled object types or (2) tries to default tostring.The second fix is probably the right one, but it may hurt compilation/IDE performance, so I'll leave it to the contributors to decide whether to make that change.