@@ -28,6 +28,13 @@ import type { PluginsInjections } from './runtime/plugins/01.plugin'
2828import { LocaleManager } from './locale-manager'
2929import { isInternalPath } from './utils'
3030
31+ // Interface for Nuxt's advanced options with generate
32+ interface NuxtOptionsWithGenerate {
33+ generate ?: {
34+ routes ?: string [ ]
35+ }
36+ }
37+
3138function generateI18nTypes ( ) {
3239 return `
3340import type {PluginsInjections} from "nuxt-i18n-micro";
@@ -287,9 +294,9 @@ export default defineNuxtModule<ModuleOptions>({
287294 pages . push ( fallbackRoute )
288295 }
289296 if ( ! isNoPrefixStrategy ( options . strategy ! ) ) {
290- // @ts -ignore - generate может не существовать в новых версиях Nuxt
291- ; ( nuxt . options as any ) . generate = ( nuxt . options as any ) . generate || { }
292- ; ( nuxt . options as any ) . generate . routes = Array . isArray ( ( nuxt . options as any ) . generate . routes ) ? ( nuxt . options as any ) . generate . routes : [ ]
297+ const nuxtOptions = nuxt . options as NuxtOptionsWithGenerate
298+ nuxtOptions . generate = nuxtOptions . generate || { }
299+ nuxtOptions . generate . routes = Array . isArray ( nuxtOptions . generate . routes ) ? nuxtOptions . generate . routes : [ ]
293300
294301 if ( isCloudflarePages ) {
295302 const processPageWithChildren = ( page : NuxtPage , parentPath = '' ) => {
@@ -432,10 +439,10 @@ export default defineNuxtModule<ModuleOptions>({
432439
433440 const routes = nitroConfig . prerender ?. routes || [ ]
434441
435- // @ts -ignore - generate может не существовать в новых версиях Nuxt
436- ; ( nuxt . options as any ) . generate = ( nuxt . options as any ) . generate || { }
437- ; ( nuxt . options as any ) . generate . routes = Array . isArray ( ( nuxt . options as any ) . generate . routes ) ? ( nuxt . options as any ) . generate . routes : [ ]
438- const pages = ( nuxt . options as any ) . generate . routes || [ ]
442+ const nuxtOptions = nuxt . options as NuxtOptionsWithGenerate
443+ nuxtOptions . generate = nuxtOptions . generate || { }
444+ nuxtOptions . generate . routes = Array . isArray ( nuxtOptions . generate . routes ) ? nuxtOptions . generate . routes : [ ]
445+ const pages = nuxtOptions . generate . routes || [ ]
439446
440447 localeManager . locales . forEach ( ( locale ) => {
441448 // Для стратегий prefix и prefix_and_default генерируем маршруты и для defaultLocale
0 commit comments