nuxt-typed-router 2.2.2-beta.0 → 2.2.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.ts +35 -7
- package/dist/module.json +1 -1
- package/dist/module.mjs +23 -17
- package/package.json +6 -5
package/dist/module.d.ts
CHANGED
|
@@ -7,26 +7,54 @@ interface ModuleOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
plugin?: boolean;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Customise Route location arguments strictness for `NuxtLink` or `router`
|
|
11
|
+
* All strict options are disabled by default.
|
|
12
|
+
* You can tweak options to add strict router navigation options.
|
|
13
|
+
*
|
|
14
|
+
* By passing `true` you can enable all of them
|
|
12
15
|
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* router.push('/login'); // Error ❌
|
|
15
|
-
* ```
|
|
16
16
|
* @default false
|
|
17
17
|
*/
|
|
18
18
|
strict?: boolean | StrictOptions;
|
|
19
19
|
}
|
|
20
20
|
interface StrictOptions {
|
|
21
|
-
NuxtLink
|
|
22
|
-
router
|
|
21
|
+
NuxtLink?: StrictParamsOptions;
|
|
22
|
+
router?: StrictParamsOptions;
|
|
23
23
|
}
|
|
24
24
|
interface StrictParamsOptions {
|
|
25
25
|
/**
|
|
26
|
+
* Prevent passing string path to the RouteLocation argument.
|
|
27
|
+
*
|
|
28
|
+
* Ex:
|
|
29
|
+
* ```vue
|
|
30
|
+
* <template>
|
|
31
|
+
* <NuxtLink to='/login'/> // Error ❌
|
|
32
|
+
* </template>
|
|
33
|
+
* ```
|
|
34
|
+
* Or
|
|
35
|
+
* ```ts
|
|
36
|
+
* router.push('/login'); // Error ❌
|
|
37
|
+
* navigateTo('/login'); // Error ❌
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
26
40
|
* @default false
|
|
27
41
|
*/
|
|
28
42
|
strictToArgument?: boolean;
|
|
29
43
|
/**
|
|
44
|
+
* Prevent passing a `params` property in the RouteLocation argument.
|
|
45
|
+
*
|
|
46
|
+
* Ex:
|
|
47
|
+
* ```vue
|
|
48
|
+
* <template>
|
|
49
|
+
* <NuxtLink :to='{path: "/login"}'/> // Error ❌
|
|
50
|
+
* </template>
|
|
51
|
+
* ```
|
|
52
|
+
* Or
|
|
53
|
+
* ```ts
|
|
54
|
+
* router.push({path: "/login"}); // Error ❌
|
|
55
|
+
* navigateTo({path: "/login"}); // Error ❌
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
30
58
|
* @default false
|
|
31
59
|
*/
|
|
32
60
|
strictRouteLocation?: boolean;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -209,6 +209,7 @@ function createTypedRouterFile() {
|
|
|
209
209
|
RouteLocationNormalizedLoaded,
|
|
210
210
|
RouteLocationRaw,
|
|
211
211
|
Router,
|
|
212
|
+
RouteLocationPathRaw
|
|
212
213
|
} from 'vue-router';
|
|
213
214
|
import type {
|
|
214
215
|
RoutesNamedLocations,
|
|
@@ -227,22 +228,26 @@ function createTypedRouterFile() {
|
|
|
227
228
|
* {@link RouteLocationRaw}
|
|
228
229
|
* */
|
|
229
230
|
export type TypedRouteLocationRaw =
|
|
230
|
-
| (Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
231
|
+
| (Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'> & RoutesNamedLocations)
|
|
232
|
+
${returnIfFalse(strictOptions.router.strictToArgument, "| string")}
|
|
233
|
+
${returnIfTrue(
|
|
234
|
+
strictOptions.router.strictRouteLocation,
|
|
235
|
+
`| Omit<RouteLocationPathRaw, 'path'>`,
|
|
236
|
+
"| RouteLocationPathRaw"
|
|
237
|
+
)};
|
|
235
238
|
|
|
236
239
|
|
|
237
240
|
/**
|
|
238
241
|
* Alternative version of {@link TypedRouteLocationRaw} but with a name generic
|
|
239
242
|
*/
|
|
240
243
|
export type TypedRouteLocationRawFromName<T extends RoutesNamesList> =
|
|
241
|
-
| (Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
| (Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'> & TypedLocationAsRelativeRaw<T>)
|
|
245
|
+
${returnIfFalse(strictOptions.router.strictToArgument, "| string")}
|
|
246
|
+
${returnIfTrue(
|
|
247
|
+
strictOptions.router.strictRouteLocation,
|
|
248
|
+
`| Omit<RouteLocationPathRaw, 'path'>`,
|
|
249
|
+
"| RouteLocationPathRaw"
|
|
250
|
+
)}
|
|
246
251
|
|
|
247
252
|
/**
|
|
248
253
|
* Generic providing inference and dynamic inclusion of \`params\` property
|
|
@@ -352,7 +357,7 @@ function createTypedRouterDefinitionFile() {
|
|
|
352
357
|
|
|
353
358
|
import type { NuxtLinkProps } from '#app';
|
|
354
359
|
import type { DefineComponent } from 'vue';
|
|
355
|
-
import type { RouteLocationRaw } from 'vue-router';
|
|
360
|
+
import type { RouteLocationRaw, RouteLocationPathRaw } from 'vue-router';
|
|
356
361
|
import type { RoutesNamedLocations, RoutesNamesListRecord } from './__routes';
|
|
357
362
|
import type {TypedRouter, TypedRoute} from './__router';
|
|
358
363
|
import { useRoute as _useRoute } from './__useTypedRoute';
|
|
@@ -372,13 +377,14 @@ function createTypedRouterDefinitionFile() {
|
|
|
372
377
|
}
|
|
373
378
|
|
|
374
379
|
type TypedNuxtLinkProps = Omit<NuxtLinkProps, 'to'> & {
|
|
375
|
-
to:
|
|
376
|
-
|
|
377
|
-
"string
|
|
378
|
-
|
|
380
|
+
to:
|
|
381
|
+
Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'> & RoutesNamedLocations
|
|
382
|
+
${returnIfFalse(strictOptions.NuxtLink.strictToArgument, "| string")}
|
|
383
|
+
${returnIfTrue(
|
|
379
384
|
strictOptions.NuxtLink.strictRouteLocation,
|
|
380
|
-
`| 'path'
|
|
381
|
-
|
|
385
|
+
`| Omit<RouteLocationPathRaw, 'path'>`,
|
|
386
|
+
"| RouteLocationPathRaw"
|
|
387
|
+
)}
|
|
382
388
|
};
|
|
383
389
|
|
|
384
390
|
export type TypedNuxtLink = DefineComponent<
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-typed-router",
|
|
3
|
-
"version": "2.2.2-beta.
|
|
3
|
+
"version": "2.2.2-beta.2",
|
|
4
4
|
"description": "Provide autocompletion for pages route names generated by Nuxt router",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/module.cjs",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"dev:build": "nuxi build playground",
|
|
22
22
|
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground && pnpm run test:prepare-fixtures",
|
|
23
23
|
"build:test": "cross-env NUXT_BUILD_TYPE=stub pnpm run prepack && pnpm run dev:build",
|
|
24
|
-
"test:prepare-fixtures": "nuxi prepare test/fixtures/simple && nuxi
|
|
24
|
+
"test:prepare-fixtures": "nuxi prepare test/fixtures/simple && nuxi prepare test/fixtures/withOptions && nuxi prepare test/fixtures/complex",
|
|
25
25
|
"test:fixtures": " vitest run --dir test",
|
|
26
26
|
"test:types": "pnpm run typecheck && pnpm run test:vue && vitest typecheck --run --dir test",
|
|
27
|
-
"test:vue": "vue-tsc -p test/fixtures/simple/tsconfig.json --noEmit && vue-tsc -p test/fixtures/complex/tsconfig.json --noEmit",
|
|
27
|
+
"test:vue": "vue-tsc -p test/fixtures/simple/tsconfig.json --noEmit && vue-tsc -p test/fixtures/complex/tsconfig.json --noEmit && vue-tsc -p test/fixtures/withOptions/tsconfig.json --noEmit",
|
|
28
28
|
"test": "pnpm run dev:prepare && pnpm run test:fixtures && pnpm run test:types",
|
|
29
29
|
"docs:dev": "cd docs && pnpm run dev",
|
|
30
30
|
"docs:build": "npm run dev:prepare && cd docs && nuxi generate",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@nuxt/kit": "3.1.1",
|
|
61
61
|
"chalk": "^5.2.0",
|
|
62
|
+
"defu": "^6.1.2",
|
|
62
63
|
"lodash-es": "^4.17.21",
|
|
63
64
|
"log-symbols": "^5.1.0",
|
|
64
65
|
"mkdirp": "^1.0.4",
|
|
65
66
|
"pathe": "1.1.0",
|
|
66
|
-
"prettier": "2.8.3"
|
|
67
|
-
"defu": "^6.1.2"
|
|
67
|
+
"prettier": "2.8.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@nuxt/module-builder": "^0.2.1",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"@types/prettier": "^2.7.2",
|
|
78
78
|
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
|
79
79
|
"@typescript-eslint/parser": "^5.49.0",
|
|
80
|
+
"@vue/test-utils": "^2.2.8",
|
|
80
81
|
"cross-env": "^7.0.3",
|
|
81
82
|
"eslint": "8.33.0",
|
|
82
83
|
"eslint-config-prettier": "^8.6.0",
|