diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index eb9f1e3cf34..c2dd4c44075 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -2020,7 +2020,7 @@ namespace ts { export function getFileNamesFromConfigSpecs(spec: ConfigFileSpecs, basePath: string, options: CompilerOptions, host: ParseConfigHost, extraFileExtensions: ReadonlyArray = []): ExpandResult { basePath = normalizePath(basePath); - const keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; + const keyMapper = host.useCaseSensitiveFileNames ? identity : toLowerCase; // Literal file names (provided via the "files" array in tsconfig.json) are stored in a // file map with a possibly case insensitive key. We use this map later when when including @@ -2224,24 +2224,6 @@ namespace ts { } } - /** - * Gets a case sensitive key. - * - * @param key The original key. - */ - function caseSensitiveKeyMapper(key: string) { - return key; - } - - /** - * Gets a case insensitive key. - * - * @param key The original key. - */ - function caseInsensitiveKeyMapper(key: string) { - return key.toLowerCase(); - } - /** * Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed. * Also converts enum values back to strings. diff --git a/src/compiler/core.ts b/src/compiler/core.ts index d92a02661e8..75564779280 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1455,6 +1455,9 @@ namespace ts { /** Returns its argument. */ export function identity(x: T) { return x; } + /** Returns the lower case string */ + export function toLowerCase(x: string) { return x.toLowerCase(); } + /** Throws an error because a function is not implemented. */ export function notImplemented(): never { throw new Error("Not implemented"); @@ -2925,9 +2928,7 @@ namespace ts { export type GetCanonicalFileName = (fileName: string) => string; export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): GetCanonicalFileName { - return useCaseSensitiveFileNames - ? ((fileName) => fileName) - : ((fileName) => fileName.toLowerCase()); + return useCaseSensitiveFileNames ? identity : toLowerCase; } /**