Skip to content

Commit dc18707

Browse files
committed
fix: type auto-completion for path prop
1 parent 993c00d commit dc18707

File tree

2 files changed

+7
-4
lines changed
  • packages/next/src/server/lib/router-utils
  • test/e2e/app-dir/typed-routes/app/dashboard

2 files changed

+7
-4
lines changed

packages/next/src/server/lib/router-utils/typegen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export type LinkPropsWithPath<T extends Routes> = LinkRestProps &
373373
href?: never;
374374
});
375375
376-
export type LinkProps<RouteType extends string = string> =
376+
export type LinkProps<RouteType extends string = Routes> =
377377
| LinkPropsWithHref<RouteType>
378378
| (RouteType extends Routes ? LinkPropsWithPath<RouteType> : never);
379379
@@ -400,7 +400,7 @@ declare module 'next/link' {
400400
* </Link>
401401
* \`\`\`
402402
*/
403-
export default function Link<RouteType extends string = string>(
403+
export default function Link<RouteType extends string = Routes>(
404404
props: LinkProps<RouteType> & { children: React.ReactNode }
405405
): JSX.Element;
406406
}

test/e2e/app-dir/typed-routes/app/dashboard/page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ export default function DashboardPage(props: PageProps<'/dashboard'>) {
44
return (
55
<div>
66
<p>Dashboard Home</p>
7-
<Link href="/shop/">Settings</Link>
8-
<Link href="/about">About</Link>
7+
<Link href="/shop/testing/hello">Settings</Link>
8+
<Link href="/blog/hey">About</Link>
9+
<Link path="/blog/[slug]" params={{ slug: 'hey' }}>
10+
Hey
11+
</Link>
912
</div>
1013
)
1114
}

0 commit comments

Comments
 (0)