Skip to content

Commit 04c6f1a

Browse files
committed
test: add back test with a param directly
1 parent 15aa272 commit 04c6f1a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/router/__tests__/routeLocation.test-d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
RouteLocationNormalizedTypedList,
99
} from '../src'
1010

11-
// TODO: could we move this to an .d.ts file that is only loaded for tests?
11+
// NOTE: A type allows us to make it work only in this test file
1212
// https://github.com/microsoft/TypeScript/issues/15300
1313
type RouteNamedMap = {
1414
home: RouteRecordInfo<'/', '/', Record<never, never>, Record<never, never>>
@@ -73,7 +73,13 @@ describe('Route Location types', () => {
7373
name: Name,
7474
fn: (to: RouteLocationNormalizedTypedList<RouteNamedMap>[Name]) => void
7575
): void
76-
function withRoute<Name extends RouteRecordName>(...args: unknown[]) {}
76+
function withRoute<_Name extends RouteRecordName>(..._args: unknown[]) {}
77+
78+
withRoute('/[other]', to => {
79+
expectTypeOf(to.params).toEqualTypeOf<{ other: string }>()
80+
expectTypeOf(to.params).not.toEqualTypeOf<{ gid: string }>()
81+
expectTypeOf(to.params).not.toEqualTypeOf<{ notExisting: string }>()
82+
})
7783

7884
withRoute('/groups/[gid]', to => {
7985
expectTypeOf(to.params).toEqualTypeOf<{ gid: string }>()

0 commit comments

Comments
 (0)