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

Add Route and LinkProps stub generics #54226

Merged
merged 3 commits into from Aug 18, 2023
Merged

Add Route and LinkProps stub generics #54226

merged 3 commits into from Aug 18, 2023

Conversation

shuding
Copy link
Member

@shuding shuding commented Aug 18, 2023

Closes #53732. Closes #52929.

When using the statically typed routes feature, we might have code like:

export function Card<T extends string>({ href }: { href: Route<T> | URL })...
export function Card<T extends string>({ href }: LinkProps<T>)...

To statically check <Card href={...}> and make sure it's href is an existing route. However, in certain cases these route types are not generated (e.g. running tsc directly w/o a next dev or next build), which results in TS errors.

This PR adds stub generics to Route and LinkProps so even if that plugin isn't executed, these types will not block type checking.

@kodiakhq kodiakhq bot merged commit b25407e into canary Aug 18, 2023
49 of 52 checks passed
@kodiakhq kodiakhq bot deleted the shu/cb31 branch August 18, 2023 14:41
@github-actions github-actions bot added the locked label Sep 2, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

typedRoutes: type overrides generated in .next, gitignored, tsc unreliable in CI Next-link props
3 participants