Use toLowercase as utility function

This commit is contained in:
Sheetal Nandi
2017-11-20 18:03:18 -08:00
parent ca52f089da
commit 63a3a65ac7
2 changed files with 5 additions and 22 deletions

View File

@@ -2020,7 +2020,7 @@ namespace ts {
export function getFileNamesFromConfigSpecs(spec: ConfigFileSpecs, basePath: string, options: CompilerOptions, host: ParseConfigHost, extraFileExtensions: ReadonlyArray<JsFileExtensionInfo> = []): 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.

View File

@@ -1455,6 +1455,9 @@ namespace ts {
/** Returns its argument. */
export function identity<T>(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;
}
/**