From: daiwei Date: Wed, 18 Jun 2025 03:36:29 +0000 (+0800) Subject: feat(compiler-sfc): support ${configDir} in paths for TypeScript 5.5+ X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=49299742ace19836f27f9b315789b0188238b438;p=thirdparty%2Fvuejs%2Fcore.git feat(compiler-sfc): support ${configDir} in paths for TypeScript 5.5+ --- diff --git a/packages/compiler-sfc/src/script/resolveType.ts b/packages/compiler-sfc/src/script/resolveType.ts index 85832dfc39..60b23ca8a6 100644 --- a/packages/compiler-sfc/src/script/resolveType.ts +++ b/packages/compiler-sfc/src/script/resolveType.ts @@ -1029,6 +1029,13 @@ function resolveWithTS( if (configs.length === 1) { matchedConfig = configs[0] } else { + const [major, minor] = ts.versionMajorMinor.split('.').map(Number) + function getPattern(base: string, p: string): string { + return p.startsWith('${configDir}') && major >= 5 && minor >= 5 + ? // ts 5.5+ supports ${configDir} in paths + p.replace('${configDir}', dirname(configPath!)) + : joinPaths(base, p) + } // resolve which config matches the current file for (const c of configs) { const base = normalizePath( @@ -1039,11 +1046,11 @@ function resolveWithTS( const excluded: string[] | undefined = c.config.raw?.exclude if ( (!included && (!base || containingFile.startsWith(base))) || - included?.some(p => isMatch(containingFile, joinPaths(base, p))) + included?.some(p => isMatch(containingFile, getPattern(base, p))) ) { if ( excluded && - excluded.some(p => isMatch(containingFile, joinPaths(base, p))) + excluded.some(p => isMatch(containingFile, getPattern(base, p))) ) { continue }