nuxt-typed-router 3.0.9 → 3.1.0-beta.0

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 CHANGED
@@ -2,13 +2,12 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
4
  /**
5
- * ⛔️ Experimental, disable it if you encounter problems
6
5
  *
7
6
  * Enables path autocomplete and path validity for programmatic validation
8
7
  *
9
8
  * @default true
10
9
  */
11
- experimentalPathCheck?: boolean;
10
+ pathCheck?: boolean;
12
11
  /**
13
12
  * Set to false if you don't want a plugin generated
14
13
  * @default false
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "nuxt": "^3.0.0",
6
6
  "bridge": false
7
7
  },
8
- "version": "3.0.9"
8
+ "version": "3.1.0-beta.0"
9
9
  }
package/dist/module.mjs CHANGED
@@ -16,7 +16,7 @@ class ModuleOptionsStore {
16
16
  constructor() {
17
17
  this.plugin = false;
18
18
  this.strict = false;
19
- this.experimentalPathCheck = true;
19
+ this.pathCheck = true;
20
20
  this.autoImport = false;
21
21
  this.rootDir = "";
22
22
  this.buildDir = "";
@@ -49,8 +49,8 @@ class ModuleOptionsStore {
49
49
  });
50
50
  }
51
51
  }
52
- if (options.experimentalPathCheck != null) {
53
- this.experimentalPathCheck = options.experimentalPathCheck;
52
+ if (options.pathCheck != null) {
53
+ this.pathCheck = options.pathCheck;
54
54
  }
55
55
  }
56
56
  getResolvedStrictOptions() {
@@ -317,7 +317,7 @@ function createRoutesTypesFile({
317
317
 
318
318
  function createTypedRouterFile() {
319
319
  const strictOptions = moduleOptionStore.getResolvedStrictOptions();
320
- const { i18n, experimentalPathCheck } = moduleOptionStore;
320
+ const { i18n, pathCheck } = moduleOptionStore;
321
321
  return (
322
322
  /* typescript */
323
323
  `
@@ -339,7 +339,7 @@ function createTypedRouterFile() {
339
339
  RoutesParamsRecordResolved,
340
340
  } from './__routes';
341
341
  ${returnIfTrue(
342
- experimentalPathCheck,
342
+ pathCheck,
343
343
  `import type {TypedPathParameter, RouteNameFromPath} from './__paths';`
344
344
  )}
345
345
  import type { HasOneRequiredParameter } from './__types_utils';
@@ -355,10 +355,10 @@ function createTypedRouterFile() {
355
355
  | (Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'> & RoutesNamedLocations)
356
356
  | Omit<RouteLocationPathRaw, 'path'>
357
357
  ${returnIfTrue(
358
- experimentalPathCheck && !strictOptions.router.strictRouteLocation,
358
+ pathCheck && !strictOptions.router.strictRouteLocation,
359
359
  `& {path?: TypedPathParameter<T>}`
360
360
  )}
361
- ${returnIfTrue(!experimentalPathCheck && !strictOptions.router.strictToArgument, ` | string`)}
361
+ ${returnIfTrue(!pathCheck && !strictOptions.router.strictToArgument, ` | string`)}
362
362
  ;
363
363
 
364
364
 
@@ -369,10 +369,10 @@ function createTypedRouterFile() {
369
369
  | (Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'> & TypedLocationAsRelativeRaw<T>)
370
370
  | Omit<RouteLocationPathRaw, 'path'>
371
371
  ${returnIfTrue(
372
- experimentalPathCheck && !strictOptions.router.strictRouteLocation,
372
+ pathCheck && !strictOptions.router.strictRouteLocation,
373
373
  `& {path?: TypedPathParameter<P>}`
374
374
  )}
375
- ${returnIfTrue(!experimentalPathCheck && !strictOptions.router.strictToArgument, ` | string`)}
375
+ ${returnIfTrue(!pathCheck && !strictOptions.router.strictToArgument, ` | string`)}
376
376
 
377
377
  /**
378
378
  * Generic providing inference and dynamic inclusion of \`params\` property
@@ -419,7 +419,7 @@ function createTypedRouterFile() {
419
419
  currentLocation?: TypedRouteLocationRaw
420
420
  ): TypedRouteLocationFromName<T>;
421
421
  ${returnIfTrue(
422
- experimentalPathCheck && !strictOptions.router.strictToArgument,
422
+ pathCheck && !strictOptions.router.strictToArgument,
423
423
  `resolve<T extends string>(to: TypedPathParameter<T>, currentLocation?: TypedRouteLocationRaw): TypedRouteLocationFromName<RouteNameFromPath<T>>;`
424
424
  )}
425
425
  /**
@@ -430,7 +430,7 @@ function createTypedRouterFile() {
430
430
  */
431
431
  push<T extends RoutesNamesList, P extends string>(to: TypedRouteLocationRawFromName<T, P>): Promise<NavigationFailure | void | undefined>;
432
432
  ${returnIfTrue(
433
- experimentalPathCheck && !strictOptions.router.strictToArgument,
433
+ pathCheck && !strictOptions.router.strictToArgument,
434
434
  `push<T extends string>(to: TypedPathParameter<T>): Promise<NavigationFailure | void | undefined>;`
435
435
  )}
436
436
  /**
@@ -441,7 +441,7 @@ function createTypedRouterFile() {
441
441
  */
442
442
  replace<T extends RoutesNamesList, P extends string>(to: TypedRouteLocationRawFromName<T, P>): Promise<NavigationFailure | void | undefined>;
443
443
  ${returnIfTrue(
444
- experimentalPathCheck && !strictOptions.router.strictToArgument,
444
+ pathCheck && !strictOptions.router.strictToArgument,
445
445
  `replace<T extends string>(to: TypedPathParameter<T>): Promise<NavigationFailure | void | undefined>;`
446
446
  )}
447
447
  }
@@ -487,7 +487,7 @@ function createTypedRouterFile() {
487
487
 
488
488
  function createTypedRouterDefinitionFile() {
489
489
  const strictOptions = moduleOptionStore.getResolvedStrictOptions();
490
- const { plugin, autoImport, i18n, experimentalPathCheck } = moduleOptionStore;
490
+ const { plugin, autoImport, i18n, pathCheck } = moduleOptionStore;
491
491
  return (
492
492
  /* typescript */
493
493
  `
@@ -507,7 +507,7 @@ function createTypedRouterDefinitionFile() {
507
507
 
508
508
  import {definePageMeta as _definePageMeta} from './__definePageMeta';
509
509
 
510
- ${returnIfTrue(experimentalPathCheck, `import type {TypedPathParameter} from './__paths';`)}
510
+ ${returnIfTrue(pathCheck, `import type {TypedPathParameter} from './__paths';`)}
511
511
 
512
512
 
513
513
  declare global {
@@ -533,32 +533,30 @@ function createTypedRouterDefinitionFile() {
533
533
  )}
534
534
  }
535
535
 
536
- type TypedNuxtLinkProps<T extends string> = Omit<NuxtLinkProps, 'to'> &
536
+ type TypedNuxtLinkProps<T extends string, E extends boolean = false> = Omit<NuxtLinkProps, 'to' | 'external'> &
537
537
  {
538
538
  to:
539
539
  | Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'> & RoutesNamedLocations
540
540
  | Omit<RouteLocationPathRaw, 'path'>
541
541
  ${returnIfTrue(
542
- experimentalPathCheck && !strictOptions.NuxtLink.strictRouteLocation,
543
- `& {path?: TypedPathParameter<T>}`
544
- )}
545
- ${returnIfTrue(
546
- !experimentalPathCheck && !strictOptions.NuxtLink.strictToArgument,
547
- ` | string`
542
+ pathCheck && !strictOptions.NuxtLink.strictRouteLocation,
543
+ `& {path?: (E extends true ? string : TypedPathParameter<T>)}`
548
544
  )}
545
+ ${returnIfTrue(!pathCheck && !strictOptions.NuxtLink.strictToArgument, ` | string`)}
549
546
  ${returnIfTrue(
550
- experimentalPathCheck && !strictOptions.NuxtLink.strictToArgument,
551
- ` | TypedPathParameter<T>`
552
- )}
547
+ pathCheck && !strictOptions.NuxtLink.strictToArgument,
548
+ ` | (E extends true ? string : TypedPathParameter<T>)`
549
+ )},
550
+ external?: E
553
551
  }
554
552
 
555
553
 
556
554
 
557
- export type TypedNuxtLink = new <P extends string>(props: TypedNuxtLinkProps<P>) => Omit<
555
+ export type TypedNuxtLink = new <P extends string, E extends boolean = false>(props: TypedNuxtLinkProps<P, E>) => Omit<
558
556
  typeof NuxtLink,
559
557
  '$props'
560
558
  > & {
561
- $props: TypedNuxtLinkProps<P>;
559
+ $props: TypedNuxtLinkProps<P, E>;
562
560
  };
563
561
 
564
562
  // Declare runtime-core instead of vue for compatibility issues with pnpm
@@ -590,7 +588,7 @@ function createTypedRouterDefinitionFile() {
590
588
  }
591
589
 
592
590
  function createIndexFile() {
593
- const { i18n, experimentalPathCheck } = moduleOptionStore;
591
+ const { i18n, pathCheck } = moduleOptionStore;
594
592
  return (
595
593
  /* typescript */
596
594
  `
@@ -622,7 +620,7 @@ function createIndexFile() {
622
620
  export { helpers } from './__helpers';
623
621
 
624
622
  ${returnIfTrue(
625
- experimentalPathCheck,
623
+ pathCheck,
626
624
  `export type { ValidatePath, RoutePathSchema, TypedPathParameter, RouteNameFromPath } from './__paths';`
627
625
  )}
628
626
  ${returnIfTrue(i18n, `export {useLocalePath, useLocaleRoute} from './__i18n-router';`)}
@@ -725,7 +723,7 @@ function createUseTypedRouterFile() {
725
723
 
726
724
  function createNavigateToFile() {
727
725
  const { router } = moduleOptionStore.getResolvedStrictOptions();
728
- const { experimentalPathCheck } = moduleOptionStore;
726
+ const { pathCheck } = moduleOptionStore;
729
727
  return (
730
728
  /* typescript */
731
729
  `
@@ -735,7 +733,7 @@ function createNavigateToFile() {
735
733
  import type { TypedRouteLocationRawFromName, TypedRouteFromName, TypedRoute } from './__router';
736
734
  import type { RoutesNamesList } from './__routes';
737
735
  ${returnIfTrue(
738
- experimentalPathCheck,
736
+ pathCheck,
739
737
  `import type {TypedPathParameter, RouteNameFromPath} from './__paths';`
740
738
  )}
741
739
 
@@ -756,7 +754,7 @@ function createNavigateToFile() {
756
754
  options?: NavigateToOptions
757
755
  ) : Promise<void | NavigationFailure | TypedRouteFromName<T>>
758
756
  ${returnIfTrue(
759
- experimentalPathCheck && !router.strictToArgument,
757
+ pathCheck && !router.strictToArgument,
760
758
  `<T extends string>(
761
759
  to: TypedPathParameter<T>,
762
760
  options?: NavigateToOptions
@@ -795,7 +793,7 @@ function createTypeUtilsRuntimeFile() {
795
793
 
796
794
  function createi18nRouterFile() {
797
795
  const { router } = moduleOptionStore.getResolvedStrictOptions();
798
- const { i18nOptions, experimentalPathCheck, i18nLocales } = moduleOptionStore;
796
+ const { i18nOptions, pathCheck, i18nLocales } = moduleOptionStore;
799
797
  return (
800
798
  /* typescript */
801
799
  `
@@ -804,7 +802,7 @@ function createi18nRouterFile() {
804
802
  import type {TypedRouteLocationRawFromName, TypedLocationAsRelativeRaw, TypedRouteFromName} from './__router';
805
803
  import type {RoutesNamesList} from './__routes';
806
804
  ${returnIfTrue(
807
- experimentalPathCheck,
805
+ pathCheck,
808
806
  `import type {TypedLocalePathParameter, RouteNameFromLocalePath} from './__paths';`
809
807
  )}
810
808
 
@@ -818,7 +816,7 @@ function createi18nRouterFile() {
818
816
  (Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'> & TypedLocationAsRelativeRaw<T>)
819
817
  >
820
818
  ${returnIfTrue(
821
- experimentalPathCheck && !router.strictToArgument,
819
+ pathCheck && !router.strictToArgument,
822
820
  `<T extends string>(
823
821
  to: TypedLocalePathParameter<T>,
824
822
  locale?: I18nLocales | undefined
@@ -833,7 +831,7 @@ function createi18nRouterFile() {
833
831
  export interface TypedLocaleRoute {
834
832
  <T extends RoutesNamesList, P extends string>(to: TypedRouteLocationRawFromName<T, P>, locale?: I18nLocales | undefined) : TypedRouteFromName<T>
835
833
  ${returnIfTrue(
836
- experimentalPathCheck && !router.strictToArgument,
834
+ pathCheck && !router.strictToArgument,
837
835
  ` <T extends string>(to: TypedLocalePathParameter<T>, locale?: I18nLocales | undefined) : TypedRouteFromName<RouteNameFromLocalePath<T>>;`
838
836
  )}
839
837
  }
@@ -1057,7 +1055,7 @@ function createPathsFiles({ routesPaths }) {
1057
1055
 
1058
1056
  function createDefinePageMetaFile() {
1059
1057
  const strictOptions = moduleOptionStore.getResolvedStrictOptions();
1060
- const { experimentalPathCheck } = moduleOptionStore;
1058
+ const { pathCheck } = moduleOptionStore;
1061
1059
  return (
1062
1060
  /* typescript */
1063
1061
  `
@@ -1066,7 +1064,7 @@ function createDefinePageMetaFile() {
1066
1064
  import type {PageMeta, NuxtError} from '#app'
1067
1065
  import type {TypedRouteFromName, TypedRoute, TypedRouteLocationRawFromName, TypedRouteLocationRaw} from './__router';
1068
1066
  import type {RoutesNamesList} from './__routes';
1069
- ${returnIfTrue(experimentalPathCheck, `import type {TypedPathParameter} from './__paths';`)}
1067
+ ${returnIfTrue(pathCheck, `import type {TypedPathParameter} from './__paths';`)}
1070
1068
 
1071
1069
  type FilteredPageMeta = {
1072
1070
  [T in keyof PageMeta as [unknown] extends [PageMeta[T]] ? never : T]: PageMeta[T];
@@ -1118,7 +1116,7 @@ export function definePageMeta<P extends string, U extends RoutesNamesList>(
1118
1116
  meta: TypedPageMeta<never> & { redirect: TypedRouteLocationRawFromName<U, P> }
1119
1117
  ): void;
1120
1118
  ${returnIfTrue(
1121
- experimentalPathCheck && !strictOptions.router.strictToArgument,
1119
+ pathCheck && !strictOptions.router.strictToArgument,
1122
1120
  `export function definePageMeta<P extends string>(
1123
1121
  meta: TypedPageMeta<never> & { redirect: TypedPathParameter<P> }
1124
1122
  ): void;`
@@ -1126,7 +1124,7 @@ ${returnIfTrue(
1126
1124
  export function definePageMeta<P extends string = string>(
1127
1125
  meta: TypedPageMeta<never> & {
1128
1126
  redirect?: (to: TypedRoute) => TypedRouteLocationRaw<P> ${returnIfTrue(
1129
- experimentalPathCheck && !strictOptions.router.strictToArgument,
1127
+ pathCheck && !strictOptions.router.strictToArgument,
1130
1128
  ` | TypedPathParameter<P>`
1131
1129
  )};
1132
1130
  }
@@ -1134,7 +1132,7 @@ export function definePageMeta<P extends string = string>(
1134
1132
  export function definePageMeta<P extends string = string>(
1135
1133
  meta: TypedPageMeta<never> & {
1136
1134
  redirect?: () => TypedRouteLocationRaw<P> ${returnIfTrue(
1137
- experimentalPathCheck && !strictOptions.router.strictToArgument,
1135
+ pathCheck && !strictOptions.router.strictToArgument,
1138
1136
  ` | TypedPathParameter<P>`
1139
1137
  )};
1140
1138
  }
@@ -1145,7 +1143,7 @@ export function definePageMeta<
1145
1143
  U extends RoutesNamesList
1146
1144
  >(routeName: T, meta: TypedPageMeta<T> & { redirect: TypedRouteLocationRawFromName<U, P> }): void;
1147
1145
  ${returnIfTrue(
1148
- experimentalPathCheck && !strictOptions.router.strictToArgument,
1146
+ pathCheck && !strictOptions.router.strictToArgument,
1149
1147
  `export function definePageMeta<T extends RoutesNamesList, P extends string>(
1150
1148
  routeName: T,
1151
1149
  meta: TypedPageMeta<T> & { redirect: TypedPathParameter<P> }
@@ -1159,7 +1157,7 @@ export function definePageMeta<
1159
1157
  routeName: T,
1160
1158
  meta: TypedPageMeta<T> & {
1161
1159
  redirect?: (to: TypedRouteFromName<T>) => TypedRouteLocationRaw<P> ${returnIfTrue(
1162
- experimentalPathCheck && !strictOptions.router.strictToArgument,
1160
+ pathCheck && !strictOptions.router.strictToArgument,
1163
1161
  ` | TypedPathParameter<P>`
1164
1162
  )};
1165
1163
  }
@@ -1168,7 +1166,7 @@ export function definePageMeta<T extends RoutesNamesList, P extends string>(
1168
1166
  routeName: T,
1169
1167
  meta: TypedPageMeta<T> & {
1170
1168
  redirect?: () => TypedRouteLocationRaw<P> ${returnIfTrue(
1171
- experimentalPathCheck && !strictOptions.router.strictToArgument,
1169
+ pathCheck && !strictOptions.router.strictToArgument,
1172
1170
  ` | TypedPathParameter<P>`
1173
1171
  )};
1174
1172
  }
@@ -1187,7 +1185,7 @@ export function definePageMeta(metaOrName: any, meta?: any): void {
1187
1185
  }
1188
1186
 
1189
1187
  function createHelpersFile() {
1190
- const { experimentalPathCheck } = moduleOptionStore;
1188
+ const { pathCheck } = moduleOptionStore;
1191
1189
  return (
1192
1190
  /* typescript */
1193
1191
  `
@@ -1198,7 +1196,7 @@ function createHelpersFile() {
1198
1196
  import type { TypedRouteLocationRawFromName, TypedLocationAsRelativeRaw } from './__router';
1199
1197
  import type { RoutesNamesList } from './__routes';
1200
1198
  ${returnIfTrue(
1201
- experimentalPathCheck,
1199
+ pathCheck,
1202
1200
  `import type {TypedPathParameter, RouteNameFromPath} from './__paths';`
1203
1201
  )}
1204
1202
 
@@ -1381,7 +1379,7 @@ async function saveGeneratedFiles({ outputData }) {
1381
1379
  console.log(
1382
1380
  logSymbols.warning,
1383
1381
  chalk.yellow(
1384
- `Route path autocomplete is still experimental. You can disable it with the "nuxtTypedRouter.experimentalPathCheck: false" option`
1382
+ `Route path autocomplete is still experimental. You can disable it with the "nuxtTypedRouter.pathCheck: false" option`
1385
1383
  )
1386
1384
  );
1387
1385
  }
@@ -1666,7 +1664,7 @@ const module = defineNuxtModule({
1666
1664
  defaults: {
1667
1665
  plugin: false,
1668
1666
  strict: false,
1669
- experimentalPathCheck: true,
1667
+ pathCheck: true,
1670
1668
  experimentalRemoveNuxtDefs: true
1671
1669
  },
1672
1670
  setup(moduleOptions, nuxt) {
@@ -1700,7 +1698,7 @@ const module = defineNuxtModule({
1700
1698
  };
1701
1699
  nuxt.hook("prepare:types", (options) => {
1702
1700
  options.tsConfig.include?.unshift("./typed-router/typed-router.d.ts");
1703
- if (moduleOptions.experimentalPathCheck) {
1701
+ if (moduleOptions.pathCheck) {
1704
1702
  options.tsConfig.vueCompilerOptions = {
1705
1703
  jsxTemplates: true,
1706
1704
  experimentalRfc436: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-typed-router",
3
- "version": "3.0.9",
3
+ "version": "3.1.0-beta.0",
4
4
  "description": "Provide autocompletion for routes paths, names and params in Nuxt apps",
5
5
  "type": "module",
6
6
  "main": "./dist/module.cjs",
@@ -59,43 +59,43 @@
59
59
  "url": "https://github.com/victorgarciaesgi/nuxt-typed-router/issues"
60
60
  },
61
61
  "dependencies": {
62
- "@nuxt/kit": "^3.3.1",
62
+ "@nuxt/kit": "^3.3.2",
63
63
  "chalk": "^5.2.0",
64
64
  "defu": "^6.1.2",
65
65
  "lodash-es": "^4.17.21",
66
66
  "log-symbols": "^5.1.0",
67
- "mkdirp": "^2.1.5",
68
- "nanoid": "^4.0.1",
67
+ "mkdirp": "^2.1.6",
68
+ "nanoid": "^4.0.2",
69
69
  "pathe": "1.1.0",
70
- "prettier": "2.8.6"
70
+ "prettier": "2.8.7"
71
71
  },
72
72
  "devDependencies": {
73
- "@nuxt/devtools": "^0.2.5",
73
+ "@nuxt/devtools": "^0.3.1",
74
74
  "@nuxt/module-builder": "^0.2.1",
75
- "@nuxt/test-utils": "^3.3.1",
75
+ "@nuxt/test-utils": "^3.3.2",
76
76
  "@nuxt/types": "^2.16.3",
77
77
  "@nuxtjs/eslint-config-typescript": "^12.0.0",
78
78
  "@nuxtjs/i18n": "8.0.0-beta.9",
79
79
  "@nuxtjs/web-vitals": "^0.2.4",
80
80
  "@types/lodash-es": "^4.17.7",
81
- "@types/node": "^18.15.5",
81
+ "@types/node": "^18.15.11",
82
82
  "@types/prettier": "^2.7.2",
83
- "@typescript-eslint/eslint-plugin": "^5.56.0",
84
- "@typescript-eslint/parser": "^5.56.0",
83
+ "@typescript-eslint/eslint-plugin": "^5.57.0",
84
+ "@typescript-eslint/parser": "^5.57.0",
85
85
  "@vue/test-utils": "^2.3.2",
86
- "bumpp": "9.0.0",
86
+ "bumpp": "9.1.0",
87
87
  "changelogithub": "0.12.7",
88
88
  "cross-env": "^7.0.3",
89
- "eslint": "8.36.0",
89
+ "eslint": "8.37.0",
90
90
  "eslint-config-prettier": "^8.8.0",
91
- "eslint-plugin-vue": "^9.9.0",
92
- "nuxt": "3.3.1",
91
+ "eslint-plugin-vue": "^9.10.0",
92
+ "nuxt": "3.3.2",
93
93
  "nuxt-seo-kit": "1.3.5",
94
- "playwright": "1.31.2",
95
- "tsd": "^0.28.0",
96
- "typescript": "^5.0.2",
97
- "vitest": "^0.29.7",
98
- "vue-eslint-parser": "^9.1.0",
94
+ "playwright": "1.32.1",
95
+ "tsd": "^0.28.1",
96
+ "typescript": "^5.0.3",
97
+ "vitest": "^0.29.8",
98
+ "vue-eslint-parser": "^9.1.1",
99
99
  "vue-router": "^4.1.6",
100
100
  "vue-tsc": "^1.1.7"
101
101
  }