Skip to content

Commit d25fd23

Browse files
Declare 'sum' so that it doesn't require type arguments.
1 parent bb3253e commit d25fd23

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ namespace ts {
8383
// extra cost of calling `getParseTreeNode` when calling these functions from inside the
8484
// checker.
8585
const checker: TypeChecker = {
86-
getNodeCount: () => sum<"nodeCount">(host.getSourceFiles(), "nodeCount"),
87-
getIdentifierCount: () => sum<"identifierCount">(host.getSourceFiles(), "identifierCount"),
88-
getSymbolCount: () => sum<"symbolCount">(host.getSourceFiles(), "symbolCount") + symbolCount,
86+
getNodeCount: () => sum(host.getSourceFiles(), "nodeCount"),
87+
getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"),
88+
getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount,
8989
getTypeCount: () => typeCount,
9090
isUndefinedSymbol: symbol => symbol === undefinedSymbol,
9191
isArgumentsSymbol: symbol => symbol === argumentsSymbol,

src/compiler/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,10 @@ namespace ts {
700700
return result;
701701
}
702702

703-
export function sum<K extends string>(array: { [x in K]: number }[], prop: K): number {
703+
export function sum<T extends Record<K, number>, K extends string>(array: T[], prop: K): number {
704704
let result = 0;
705705
for (const v of array) {
706-
result += v[prop];
706+
result += (v[prop] as number);
707707
}
708708
return result;
709709
}

0 commit comments

Comments
 (0)