diff --git a/packages/nuxt/src/core/templates.ts b/packages/nuxt/src/core/templates.ts index fa2a0274e5..d972a06352 100644 --- a/packages/nuxt/src/core/templates.ts +++ b/packages/nuxt/src/core/templates.ts @@ -110,6 +110,8 @@ declare module '#app/defaults' { }, } +const TS_RE = /\.[cm]?tsx?$/ + export const pluginsDeclaration: NuxtTemplate = { filename: 'types/plugins.d.ts', getContents: async ({ nuxt, app }) => { @@ -138,9 +140,14 @@ export const pluginsDeclaration: NuxtTemplate = { } if (exists(pluginPath)) { - tsImports.push(relativePath.replace(EXTENSION_RE, '')) - continue + if (TS_RE.test(pluginPath)) { + tsImports.push(relativePath.replace(EXTENSION_RE, '')) + continue + } + tsImports.push(relativePath) } + + // No declaration found that TypeScript can use } return `// Generated by Nuxt'