Skip to content

Commit 958a1ad

Browse files
committed
docs: note about generic route record name
1 parent d1e3e95 commit 958a1ad

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

packages/router/src/typed-routes/route-location.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ import type { _LiteralUnion } from '../types/utils'
1111
import type { RouteMap, RouteMapGeneric } from './route-map'
1212
import type { Router } from '../router'
1313
import type { RouteRecord, RouteRecordNormalized } from '../matcher/types'
14-
import { RouteRecordNameGeneric } from './route-records'
15-
16-
/**
17-
* Possible values for a user-defined route record's name.
18-
*/
19-
export type RouteRecordName = RouteMapGeneric extends RouteMap
20-
? RouteRecordNameGeneric
21-
: keyof RouteMap
14+
import type { RouteRecordName, RouteRecordNameGeneric } from './route-records'
2215

2316
/**
2417
* Generic version of {@link RouteLocation}. It is used when no {@link RouteMap} is provided.

packages/router/src/typed-routes/route-records.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {
1+
import type {
22
RouteLocation,
33
RouteLocationNormalized,
44
RouteLocationRaw,
55
} from './route-location'
6-
import { RouteMap } from './route-map'
6+
import type { RouteMap, RouteMapGeneric } from './route-map'
77

88
/**
99
* @internal
@@ -17,6 +17,15 @@ export type RouteRecordRedirectOption =
1717
*/
1818
export type RouteRecordNameGeneric = string | symbol | undefined
1919

20+
/**
21+
* Possible values for a user-defined route record's name.
22+
*
23+
* NOTE: since `RouteRecordName` is a type, it evaluates too early and it's always be {@link RouteRecordNameGeneric}. If you need a typed version use {@link RouteMap | `keyof RouteMap`}
24+
*/
25+
export type RouteRecordName = RouteMapGeneric extends RouteMap
26+
? RouteRecordNameGeneric
27+
: keyof RouteMap
28+
2029
/**
2130
* @internal
2231
*/

0 commit comments

Comments
 (0)