Skip to content

Commit 48f4408

Browse files
authored
Merge pull request #16862 from Microsoft/dedupe-some-utility-code
Dedupe some utility code
2 parents f172f72 + 2eec7f3 commit 48f4408

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ namespace ts {
19301930
}
19311931

19321932
function createTypeofType() {
1933-
return getUnionType(convertToArray(typeofEQFacts.keys(), getLiteralType));
1933+
return getUnionType(arrayFrom(typeofEQFacts.keys(), getLiteralType));
19341934
}
19351935

19361936
// A reserved member name starts with two underscores, but the third character cannot be an underscore
@@ -10531,12 +10531,8 @@ namespace ts {
1053110531
}
1053210532
}
1053310533

10534-
function inferFromParameterTypes(source: Type, target: Type) {
10535-
return inferFromTypes(source, target);
10536-
}
10537-
1053810534
function inferFromSignature(source: Signature, target: Signature) {
10539-
forEachMatchingParameterType(source, target, inferFromParameterTypes);
10535+
forEachMatchingParameterType(source, target, inferFromTypes);
1054010536

1054110537
if (source.typePredicate && target.typePredicate && source.typePredicate.kind === target.typePredicate.kind) {
1054210538
inferFromTypes(source.typePredicate.type, target.typePredicate.type);

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ namespace ts {
12901290
case "object":
12911291
return {};
12921292
default:
1293-
return arrayFrom((<CommandLineOptionOfCustomType>option).type.keys())[0];
1293+
return (option as CommandLineOptionOfCustomType).type.keys().next().value;
12941294
}
12951295
}
12961296

src/compiler/core.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -996,14 +996,6 @@ namespace ts {
996996
return result;
997997
}
998998

999-
export function convertToArray<T, U>(iterator: Iterator<T>, f: (value: T) => U) {
1000-
const result: U[] = [];
1001-
for (let { value, done } = iterator.next(); !done; { value, done } = iterator.next()) {
1002-
result.push(f(value));
1003-
}
1004-
return result;
1005-
}
1006-
1007999
/**
10081000
* Calls `callback` for each entry in the map, returning the first truthy result.
10091001
* Use `map.forEach` instead for normal iteration.
@@ -2527,4 +2519,4 @@ namespace ts {
25272519
export function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) {
25282520
return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
25292521
}
2530-
}
2522+
}

0 commit comments

Comments
 (0)