-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Next-link props #52929
Labels
Comments
github-actions
bot
added
the
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
label
Jul 20, 2023
If you have It's unfortunate that I can't think of a way in TS to have generics in |
shuding
added
TypeScript
Related to types with Next.js.
and removed
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
labels
Jul 20, 2023
kodiakhq bot
pushed a commit
that referenced
this issue
Aug 18, 2023
Closes #53732. Closes #52929. When using the statically typed routes feature, we might have code like: ```ts 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.
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/runtime-resonance-rvkftd?file=%2Fsrc%2Fcomponents%2FBaseLink.tsx%3A10%2C22
codesandbox failed to reproduce.
To Reproduce
Describe the Bug
This error occurs when running tsc --pretty
Ide does not highlight this error without running the tsc --pretty command
Expected Behavior
I expected everything to be fine, because LinkProps is not Generic
Which browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
next-dev
localhost
The text was updated successfully, but these errors were encountered: