Skip to content

Commit 9dd574b

Browse files
author
Armando Aguirre
committed
Added host.useCaseSens..., memoized getDefaultLibFileName.
1 parent 88262db commit 9dd574b

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/compiler/program.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,12 @@ namespace ts {
325325
}
326326

327327
output += sys.newLine;
328-
output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `;
328+
output += `${relativeFileName}(${firstLine + 1},${firstLineChar + 1}): `;
329329
}
330330

331331
const categoryColor = getCategoryFormat(diagnostic.category);
332332
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
333-
output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`;
333+
output += `${formatAndReset(category, categoryColor)} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine)}`;
334334
output += sys.newLine;
335335
}
336336
return output;
@@ -436,7 +436,8 @@ namespace ts {
436436
host = host || createCompilerHost(options);
437437

438438
let skipDefaultLib = options.noLib;
439-
const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options));
439+
const getDefaultLibraryFileName = memoize(() => host.getDefaultLibFileName(options));
440+
const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(getDefaultLibraryFileName());
440441
const programDiagnostics = createDiagnosticCollection();
441442
const currentDirectory = host.getCurrentDirectory();
442443
const supportedExtensions = getSupportedExtensions(options);
@@ -512,12 +513,11 @@ namespace ts {
512513
// If '--lib' is not specified, include default library file according to '--target'
513514
// otherwise, using options specified in '--lib' instead of '--target' default library file
514515
if (!options.lib) {
515-
processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib*/ true);
516+
processRootFile(getDefaultLibraryFileName(), /*isDefaultLib*/ true);
516517
}
517518
else {
518-
const libDirectory = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options));
519519
forEach(options.lib, libFileName => {
520-
processRootFile(combinePaths(libDirectory, libFileName), /*isDefaultLib*/ true);
520+
processRootFile(combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true);
521521
});
522522
}
523523
}
@@ -982,11 +982,11 @@ namespace ts {
982982
return true;
983983
}
984984

985-
if (defaultLibraryPath !== undefined && defaultLibraryPath.length !== 0) {
986-
return comparePaths(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ true) === Comparison.EqualTo;
985+
if (defaultLibraryPath && defaultLibraryPath.length !== 0) {
986+
return containsPath(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ !host.useCaseSensitiveFileNames());
987987
}
988988

989-
return compareStrings(file.fileName, host.getDefaultLibFileName(options), /*ignoreCase*/ true) === Comparison.EqualTo;
989+
return compareStrings(file.fileName, getDefaultLibraryFileName(), /*ignoreCase*/ !host.useCaseSensitiveFileNames()) === Comparison.EqualTo;
990990
}
991991

992992
function getDiagnosticsProducingTypeChecker() {

0 commit comments

Comments
 (0)