Open AndreyYolkin opened 4 months ago
As workaround, I added this snippet inside d.ts file and it works:
/// <reference types="unplugin-vue-router/client" />
import type { RouteLocation, RouteLocationNormalizedLoaded, RouteLocationRaw, Router } from '#vue-router';
declare module '#i18n' {
export type StubbedLocalePathFunction = (route: RouteLocation | RouteLocationRaw, locale?: Locale) => string;
export declare function useLocalePath(): StubbedLocalePathFunction;
}
Describe the feature
According to the code here, nuxt i18n imports types from
vue-router
package: https://github.com/nuxt-modules/i18n/blob/c43842f11027253c07c45b7a9e8e6ab81bae7d54/src/runtime/composables/index.ts#L24However, nuxt itself registers
#vue-router
alias to handle both situations with enabled/disabled typed routes. Example of usage: https://github.com/nuxt/nuxt/blob/d326e054d372bd2eb5bf75f3feca6a291169ff76/packages/nuxt/src/pages/runtime/utils.ts#L2Since nuxt/i18n is a nuxt module, I suppose we can rely on this alias too and enable type imports by replacing
vue-router
with#vue-router
for types importsAdditional information
Final checks