Skip to content

Conversation

@sandersn
Copy link
Contributor

@sandersn sandersn commented Jun 29, 2020

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 anys 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 to string.

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.

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 sandersn requested a review from johnnyreilly as a code owner June 29, 2020 16:52
@typescript-bot typescript-bot added Where is GH Actions? GH Actions didn't give a response to this PR Critical package labels Jun 29, 2020
@typescript-bot
Copy link
Contributor

typescript-bot commented Jun 29, 2020

@sandersn Thank you for submitting this PR!

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by DT maintainers

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
}

@typescript-bot
Copy link
Contributor

🔔 @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 Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot typescript-bot removed the Where is GH Actions? GH Actions didn't give a response to this PR label Jun 29, 2020
@typescript-bot
Copy link
Contributor

👋 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 📊
master #45780 diff
Batch compilation
Memory usage (MiB) 153.1 149.0 -2.7%
Type count 41191 41188 0%
Assignability cache size 14511 14510 0%
Language service
Samples taken 873 873 0%
Identifiers in tests 2028 2029 0%
getCompletionsAtPosition
    Mean duration (ms) 856.4 856.1 0.0%
    Mean CV 7.7% 7.7%
    Worst duration (ms) 1247.2 1289.4 +3.4%
    Worst identifier color li
getQuickInfoAtPosition
    Mean duration (ms) 839.4 837.8 -0.2%
    Mean CV 8.1% 7.9% -2.6%
    Worst duration (ms) 1233.7 1115.5 -9.6%
    Worst identifier Route to

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Jun 29, 2020
Copy link
Member

@johnnyreilly johnnyreilly left a 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!

@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner labels Jun 29, 2020
@typescript-bot
Copy link
Contributor

@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:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

@sandersn
Copy link
Contributor Author

Ready to merge

@typescript-bot typescript-bot merged commit cbbbfec into master Jun 29, 2020
@sandersn sandersn deleted the update-react-router-hooks-test branch June 29, 2020 20:41
ngbrown pushed a commit to ngbrown-forks/DefinitelyTyped that referenced this pull request Jul 11, 2020
…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.
danielrearden pushed a commit to danielrearden/DefinitelyTyped that referenced this pull request Sep 22, 2020
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Critical package Maintainer Approved Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Self Merge This PR can now be self-merged by the PR author or an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants