Skip to content

Commit 32f78c7

Browse files
zjy040525posva
andauthored
fix: missing closing quote in generated import (#2688)
Close #2687 Co-authored-by: Eduardo San Martin Morote <posva13@gmail.com>
1 parent 7a41931 commit 32f78c7

3 files changed

Lines changed: 78 additions & 2 deletions

File tree

packages/playground-file-based/src/routes.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616
} from 'vue-router'
1717
import type {
1818
_ExtractParamParserType,
19-
} from 'vue-router/experimental
19+
} from 'vue-router/experimental'
2020

2121
// Custom route params parsers
2222
type Param_date = _ExtractParamParserType<typeof import('./params/date.ts').parser>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { generateDTS } from './generateDTS'
3+
4+
describe('generateDTS', () => {
5+
it('generates a well-formed dts file', () => {
6+
expect(
7+
generateDTS({
8+
routesModule: 'vue-router/auto-routes',
9+
routeNamedMap: 'export interface RouteNamedMap {}',
10+
routeFileInfoMap: 'export interface _RouteFileInfoMap {}',
11+
paramsTypesDeclaration: '',
12+
customParamsTypeList: [],
13+
})
14+
).toMatchInlineSnapshot(`
15+
"/* eslint-disable */
16+
/* prettier-ignore */
17+
// oxfmt-ignore
18+
// @ts-nocheck
19+
// noinspection ES6UnusedImports
20+
// Generated by vue-router. !! DO NOT MODIFY THIS FILE !!
21+
// It's recommended to commit this file.
22+
// Make sure to add this file to your tsconfig.json file as an "includes" or "files" entry.
23+
24+
import type {
25+
RouteRecordInfo,
26+
ParamValue,
27+
ParamValueOneOrMore,
28+
ParamValueZeroOrMore,
29+
ParamValueZeroOrOne,
30+
} from 'vue-router'
31+
import type {
32+
_ExtractParamParserType,
33+
} from 'vue-router/experimental'
34+
35+
declare module 'vue-router' {
36+
interface TypesConfig {
37+
ParamParsers:
38+
39+
}
40+
}
41+
42+
declare module 'vue-router/auto-routes' {
43+
/**
44+
* Route name map generated by vue-router
45+
*/
46+
export interface RouteNamedMap {}
47+
48+
/**
49+
* Route file to route info map by vue-router.
50+
* Used by the \\\`sfc-typed-router\\\` Volar plugin to automatically type \\\`useRoute()\\\`.
51+
*
52+
* Each key is a file path relative to the project root with 2 properties:
53+
* - routes: union of route names of the possible routes when in this page (passed to useRoute<...>())
54+
* - views: names of nested views (can be passed to <RouterView name="...">)
55+
*
56+
* @internal
57+
*/
58+
export interface _RouteFileInfoMap {}
59+
60+
/**
61+
* Get a union of possible route names in a certain route component file.
62+
* Used by the \\\`sfc-typed-router\\\` Volar plugin to automatically type \\\`useRoute()\\\`.
63+
*
64+
* @internal
65+
*/
66+
export type _RouteNamesForFilePath<FilePath extends string> =
67+
_RouteFileInfoMap extends Record<FilePath, infer Info>
68+
? Info['routes']
69+
: keyof RouteNamedMap
70+
}
71+
72+
export {}
73+
"
74+
`)
75+
})
76+
})

packages/router/src/unplugin/codegen/generateDTS.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import type {
4747
} from 'vue-router'
4848
import type {
4949
_ExtractParamParserType,
50-
} from 'vue-router/experimental
50+
} from 'vue-router/experimental'
5151
5252
${
5353
paramsTypesDeclaration

0 commit comments

Comments
 (0)