diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index a32a5137bad..7bf50f675aa 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -1,4 +1,4 @@
-///
+///
///
///
///
@@ -543,7 +543,7 @@ namespace ts {
/* @internal */
export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic {
- const namesOfType = keysOfMap(opt.type).map(key => `'${key}'`).join(", ");
+ const namesOfType = arrayFrom(opt.type.keys()).map(key => `'${key}'`).join(", ");
return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType);
}
@@ -1255,8 +1255,8 @@ namespace ts {
}
}
- const literalFiles = valuesOfMap(literalFileMap);
- const wildcardFiles = valuesOfMap(wildcardFileMap);
+ const literalFiles = arrayFrom(literalFileMap.values());
+ const wildcardFiles = arrayFrom(wildcardFileMap.values());
wildcardFiles.sort(host.useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive);
return {
fileNames: literalFiles.concat(wildcardFiles),
diff --git a/src/compiler/core.ts b/src/compiler/core.ts
index e9dbdb8786a..9f8f1ba3f55 100644
--- a/src/compiler/core.ts
+++ b/src/compiler/core.ts
@@ -156,7 +156,7 @@ namespace ts {
}
function getKeys() {
- return keysOfMap(files) as Path[];
+ return arrayFrom(files.keys()) as Path[];
}
// path should already be well-formed so it does not need to be normalized
@@ -867,7 +867,8 @@ namespace ts {
return keys;
}
- function arrayFrom(iterator: Iterator): T[] {
+ /** Shims `Array.from`. */
+ export function arrayFrom(iterator: Iterator): T[] {
const result: T[] = [];
for (let { value, done } = iterator.next(); !done; { value, done } = iterator.next()) {
result.push(value);
@@ -875,19 +876,6 @@ namespace ts {
return result;
}
- /**
- * Array of every key in a map.
- * May not actually return string[] if numbers were put into the map.
- */
- export function keysOfMap(map: Map<{}>): string[] {
- return arrayFrom(map.keys());
- }
-
- /** Array of every value in a map. */
- export function valuesOfMap(map: Map): T[] {
- return arrayFrom(map.values());
- }
-
/**
* Calls `callback` for each entry in the map, returning the first defined result.
* Use `map.forEach` instead for normal iteration.
diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts
index ba5a0d8faea..a0e7d5ba323 100644
--- a/src/compiler/tsc.ts
+++ b/src/compiler/tsc.ts
@@ -680,7 +680,7 @@ namespace ts {
description = getDiagnosticText(option.description);
const element = (option).element;
const typeMap =