next.js
b25407e4 - Add `Route` and `LinkProps` stub generics (#54226)

Commit
2 years ago
Add `Route` and `LinkProps` stub generics (#54226) 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.
Author
Parents
Loading