Skip to content

Commit

Permalink
fix: localePath path navigation bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
victorgarciaesgi committed Feb 4, 2023
1 parent 3ec56da commit 27743dd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuxt-typed-router",
"version": "2.3.2",
"version": "2.3.3",
"description": "Provide autocompletion for pages route names generated by Nuxt router",
"type": "module",
"main": "./dist/module.cjs",
Expand All @@ -25,7 +25,7 @@
"test:fixtures": " vitest run --dir test",
"test:types": "pnpm run typecheck && pnpm run test:vue && vitest typecheck --run --dir test",
"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",
"test": "pnpm run dev:prepare && pnpm run test:fixtures && pnpm run test:types",
"test": "pnpm run dev:prepare && pnpm run test:types && pnpm run test:fixtures",
"docs:dev": "cd docs && pnpm run dev",
"docs:build": "npm run dev:prepare && cd docs && nuxi generate",
"typecheck": "tsc --noEmit"
Expand Down
1 change: 1 addition & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default defineNuxtConfig({
modules: [NuxtTypedRouter, '@nuxtjs/i18n'],
nuxtTypedRouter: {
plugin: true,
strict: true,
},
srcDir: './src',
i18n: {
Expand Down
2 changes: 1 addition & 1 deletion playground/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const router = useRouter();
const localePath = useLocalePath();
const localeRoute = useLocaleRoute();
navigateTo(localePath({ name: 'user' }));
navigateTo(localePath('/foo'));
router.push(localePath({ name: 'user', params: { id: 1 } }));
Expand Down
4 changes: 2 additions & 2 deletions src/core/output/generators/files/__i18n-router.file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export function createi18nRouterFile() {
i18nLocales.length ? i18nLocales.map((loc) => `"${loc}"`).join('|') : 'string'
};
export type TypedToLocalePath = <T extends RoutesNamesList>(
export type TypedToLocalePath = <T extends RoutesNamesList = never>(
to: TypedRouteLocationRawFromName<T>,
locale?: I18nLocales | undefined
) => Required<TypedLocationAsRelativeRaw<T>>;
) => [T] extends [never] ? string : Required<TypedLocationAsRelativeRaw<T>>;
export function useLocalePath(options?: Pick<NonNullable<Parameters<typeof _useLocalePath>[0]>, 'i18n'>): TypedToLocalePath {
return _useLocalePath(options) as any;
Expand Down

1 comment on commit 27743dd

@vercel
Copy link

@vercel vercel bot commented on 27743dd Feb 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.