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

TS: Parameter values are optional when can't be inferred #262

Merged
merged 3 commits into from
Nov 5, 2022

Conversation

molefrog
Copy link
Owner

@molefrog molefrog commented Nov 3, 2022

Partially addresses #229
Closes #214

  • When route parameters can't be inferred at a compile time, they become optional now. Routes may contain optional segments (e.g. /:rest*) so some parameters could be undefined
  • Parameter values are now readonly

@molefrog molefrog self-assigned this Nov 3, 2022
@github-actions
Copy link

github-actions bot commented Nov 3, 2022

size-limit report 📦

Path Size
index.js 1.11 KB (0%)
use-location.js 159 B (0%)

@codecov
Copy link

codecov bot commented Nov 3, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (3349dee) compared to base (9d9ad91).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #262   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          255       255           
  Branches        50        50           
=========================================
  Hits           255       255           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@molefrog
Copy link
Owner Author

molefrog commented Nov 3, 2022

Hey @HansBrende, I hope this is still relevant. Once again, sorry for my late reply. I've updated type definitions based on your suggestions, do you mind taking a look?

Thanks!

@HansBrende
Copy link
Contributor

HansBrende commented Nov 4, 2022

@molefrog thanks! I've taken a look and it appears to be working as expected now. (Note however that I've only tested the typescript 4.1 and standard React flavors, I have not tested on Preact or out-of-date typescript versions).

Also note my comment describing how the second half of the issue I raised is fixed in the React 18 typings, but still present before React 18.

Side note: since you now seem to be back in business, I have a PR open which I've been waiting for some kind of resolution for (would love to replace the hacks in my current codebase with this simple fix) if you'd be so kind as to take a look: #231

@molefrog
Copy link
Owner Author

molefrog commented Nov 5, 2022

@molefrog thanks! I've taken a look and it appears to be working as expected now. (Note however that I've only tested the typescript 4.1 and standard React flavors, I have not tested on Preact or out-of-date typescript versions).

Also note my comment describing how the second half of the issue I raised is fixed in the React 18 typings, but still present before React 18.

Thank you for the review.

The second half of the issue is to be addresses in the next PR, I've checked it and it is a valid point.

Side note: since you now seem to be back in business, I have a PR open which I've been waiting for some kind of resolution for (would love to replace the hacks in my current codebase with this simple fix) if you'd be so kind as to take a look: #231

Yep, in my to-do list.

@molefrog molefrog merged commit 3f6ab7b into master Nov 5, 2022
@molefrog molefrog deleted the fix/ts-param-types branch November 5, 2022 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DefaultParams type doesn't count with optional parameters
2 participants