mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-14 16:56:06 -05:00
Delay the calculation of common source root if it would be needed when calculation dts files (#59070)
This commit is contained in:
@@ -4418,7 +4418,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
options.outDir || // there is --outDir specified
|
||||
options.rootDir || // there is --rootDir specified
|
||||
options.sourceRoot || // there is --sourceRoot specified
|
||||
options.mapRoot // there is --mapRoot specified
|
||||
options.mapRoot || // there is --mapRoot specified
|
||||
(getEmitDeclarations(options) && options.declarationDir) // there is --declarationDir specified
|
||||
) {
|
||||
// Precalculate and cache the common source directory
|
||||
const dir = getCommonSourceDirectory();
|
||||
|
||||
@@ -6315,15 +6315,15 @@ export function getOwnEmitOutputFilePath(fileName: string, host: EmitHost, exten
|
||||
|
||||
/** @internal */
|
||||
export function getDeclarationEmitOutputFilePath(fileName: string, host: EmitHost) {
|
||||
return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), f => host.getCanonicalFileName(f));
|
||||
return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getDeclarationEmitOutputFilePathWorker(fileName: string, options: CompilerOptions, currentDirectory: string, commonSourceDirectory: string, getCanonicalFileName: GetCanonicalFileName): string {
|
||||
export function getDeclarationEmitOutputFilePathWorker(fileName: string, options: CompilerOptions, host: Pick<EmitHost, "getCommonSourceDirectory" | "getCurrentDirectory" | "getCanonicalFileName">): string {
|
||||
const outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified
|
||||
|
||||
const path = outputDir
|
||||
? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
|
||||
? getSourceFilePathInNewDirWorker(fileName, outputDir, host.getCurrentDirectory(), host.getCommonSourceDirectory(), f => host.getCanonicalFileName(f))
|
||||
: fileName;
|
||||
const declarationExtension = getDeclarationEmitExtensionForPath(path);
|
||||
return removeFileExtension(path) + declarationExtension;
|
||||
|
||||
Reference in New Issue
Block a user