fix(kit): include declaration files when resolving compilerOptions.paths

This commit is contained in:
Daniel Roe 2025-03-04 16:41:16 +00:00
parent 7a2fbce01a
commit 835e89404f
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -146,7 +146,7 @@ export async function updateTemplates (options?: { filter?: (template: ResolvedN
return await tryUseNuxt()?.hooks.callHook('builder:generateApp', options)
}
const EXTENSION_RE = /\b\.\w+$/g
const EXTENSION_RE = /\b(?:\.d\.[cm]?ts|\.\w+)$/g
// Exclude bridge alias types to support Volar
const excludedAlias = [/^@vue\/.*$/, /^#internal\/nuxt/]
export async function _generateTypes (nuxt: Nuxt) {
@ -289,7 +289,11 @@ export async function _generateTypes (nuxt: Nuxt) {
let absolutePath = resolve(basePath, aliases[alias]!)
let stats = await fsp.stat(absolutePath).catch(() => null /* file does not exist */)
if (!stats) {
const resolvedModule = resolveModulePath(aliases[alias]!, { try: true, from: importPaths })
const resolvedModule = resolveModulePath(aliases[alias]!, {
try: true,
from: importPaths,
extensions: [...nuxt.options.extensions, '.d.ts', '.d.mts', '.d.cts'],
})
if (resolvedModule) {
absolutePath = resolvedModule
stats = await fsp.stat(resolvedModule).catch(() => null)