Skip to content

Commit 53796ee

Browse files
author
Andy
authored
Clean up lexical classifier (#20123)
1 parent a551c4c commit 53796ee

File tree

3 files changed

+344
-372
lines changed

3 files changed

+344
-372
lines changed

src/compiler/core.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,10 +1260,12 @@ namespace ts {
12601260
return result;
12611261
}
12621262

1263-
export function arrayToNumericMap<T>(array: ReadonlyArray<T>, makeKey: (value: T) => number): T[] {
1264-
const result: T[] = [];
1263+
export function arrayToNumericMap<T>(array: ReadonlyArray<T>, makeKey: (value: T) => number): T[];
1264+
export function arrayToNumericMap<T, V>(array: ReadonlyArray<T>, makeKey: (value: T) => number, makeValue: (value: T) => V): V[];
1265+
export function arrayToNumericMap<T, V>(array: ReadonlyArray<T>, makeKey: (value: T) => number, makeValue?: (value: T) => V): V[] {
1266+
const result: V[] = [];
12651267
for (const value of array) {
1266-
result[makeKey(value)] = value;
1268+
result[makeKey(value)] = makeValue ? makeValue(value) : value as any as V;
12671269
}
12681270
return result;
12691271
}

src/compiler/utilities.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5078,16 +5078,7 @@ namespace ts {
50785078
}
50795079

50805080
export function isStringTextContainingNode(node: Node) {
5081-
switch (node.kind) {
5082-
case SyntaxKind.StringLiteral:
5083-
case SyntaxKind.TemplateHead:
5084-
case SyntaxKind.TemplateMiddle:
5085-
case SyntaxKind.TemplateTail:
5086-
case SyntaxKind.NoSubstitutionTemplateLiteral:
5087-
return true;
5088-
default:
5089-
return false;
5090-
}
5081+
return node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind);
50915082
}
50925083

50935084
// Identifiers

0 commit comments

Comments
 (0)