nuxt-typed-router 3.1.0-beta.1 → 3.1.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.json +1 -1
- package/dist/module.mjs +34 -3
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -392,6 +392,27 @@ function createTypedRouterFile() {
|
|
|
392
392
|
: { params: RoutesParamsRecord[T] });
|
|
393
393
|
|
|
394
394
|
|
|
395
|
+
/**
|
|
396
|
+
* Used for type assertion:
|
|
397
|
+
*
|
|
398
|
+
* @usage
|
|
399
|
+
*
|
|
400
|
+
* \`\`\`ts
|
|
401
|
+
* const myRoute = '/foo' as TypedRouteLocation;
|
|
402
|
+
* \`\`\`
|
|
403
|
+
* */
|
|
404
|
+
export type TypedRouteLocation<T extends string = '/'> =
|
|
405
|
+
| (Omit<Exclude<RouteLocationRaw, string>, 'name' | 'params'> & RoutesNamedLocations)
|
|
406
|
+
| Omit<RouteLocationPathRaw, 'path'>
|
|
407
|
+
${returnIfTrue(
|
|
408
|
+
pathCheck && !strictOptions.router.strictRouteLocation,
|
|
409
|
+
`& {path?: TypedPathParameter<T>}`
|
|
410
|
+
)}
|
|
411
|
+
${returnIfTrue(!pathCheck && !strictOptions.router.strictToArgument, ` | string`)}
|
|
412
|
+
${returnIfTrue(pathCheck && !strictOptions.router.strictToArgument, `| TypedPathParameter<T>`)}
|
|
413
|
+
;
|
|
414
|
+
|
|
415
|
+
|
|
395
416
|
/** Augmented Router with typed methods
|
|
396
417
|
* {@link Router}
|
|
397
418
|
*/
|
|
@@ -451,6 +472,8 @@ function createTypedRouterFile() {
|
|
|
451
472
|
)}
|
|
452
473
|
}
|
|
453
474
|
|
|
475
|
+
|
|
476
|
+
|
|
454
477
|
|
|
455
478
|
|
|
456
479
|
// - Resolved normalized routes for current Location (ex: useRoute and currentRoute)
|
|
@@ -597,7 +620,8 @@ function createTypedRouterDefinitionFile() {
|
|
|
597
620
|
}
|
|
598
621
|
|
|
599
622
|
function createIndexFile() {
|
|
600
|
-
const { i18n, pathCheck } = moduleOptionStore;
|
|
623
|
+
const { i18n, i18nOptions, pathCheck } = moduleOptionStore;
|
|
624
|
+
const hasPrefixStrategy = i18n && i18nOptions?.strategy !== "no_prefix";
|
|
601
625
|
return (
|
|
602
626
|
/* typescript */
|
|
603
627
|
`
|
|
@@ -607,6 +631,7 @@ function createIndexFile() {
|
|
|
607
631
|
TypedResolvedMatcherLocation,
|
|
608
632
|
TypedRoute,
|
|
609
633
|
TypedRouteFromName,
|
|
634
|
+
TypedRouteLocation,
|
|
610
635
|
TypedRouteLocationFromName,
|
|
611
636
|
TypedRouteLocationRaw,
|
|
612
637
|
TypedRouteLocationRawFromName,
|
|
@@ -630,9 +655,15 @@ function createIndexFile() {
|
|
|
630
655
|
|
|
631
656
|
${returnIfTrue(
|
|
632
657
|
pathCheck,
|
|
633
|
-
`export type { ValidatePath, RoutePathSchema, TypedPathParameter, RouteNameFromPath
|
|
658
|
+
`export type { ValidatePath, RoutePathSchema, TypedPathParameter, RouteNameFromPath, ${returnIfTrue(
|
|
659
|
+
hasPrefixStrategy,
|
|
660
|
+
`TypedLocalePathParameter`
|
|
661
|
+
)} } from './__paths';`
|
|
662
|
+
)}
|
|
663
|
+
${returnIfTrue(
|
|
664
|
+
i18n,
|
|
665
|
+
`export {useLocalePath, useLocaleRoute, TypedToLocalePath, TypedLocaleRoute} from './__i18n-router';`
|
|
634
666
|
)}
|
|
635
|
-
${returnIfTrue(i18n, `export {useLocalePath, useLocaleRoute} from './__i18n-router';`)}
|
|
636
667
|
|
|
637
668
|
|
|
638
669
|
`
|