Skip to content

Commit 7428369

Browse files
committed
Fix grammar check for empty type argument list and compiler crash
1 parent 31f0814 commit 7428369

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/compiler/checker.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4821,7 +4821,7 @@ namespace ts {
48214821

48224822
function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[], location: Node): Signature[] {
48234823
let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
4824-
if (typeArgumentNodes) {
4824+
if (some(typeArgumentNodes)) {
48254825
const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode);
48264826
signatures = map(signatures, sig => getSignatureInstantiation(sig, typeArguments));
48274827
}
@@ -20921,7 +20921,7 @@ namespace ts {
2092120921
const staticBaseType = getApparentType(baseConstructorType);
2092220922
checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
2092320923
checkSourceElement(baseTypeNode.expression);
20924-
if (baseTypeNode.typeArguments) {
20924+
if (some(baseTypeNode.typeArguments)) {
2092520925
forEach(baseTypeNode.typeArguments, checkSourceElement);
2092620926
for (const constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode)) {
2092720927
if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) {
@@ -23896,6 +23896,11 @@ namespace ts {
2389623896
const sourceFile = getSourceFileOfNode(node);
2389723897
return grammarErrorAtPos(sourceFile, types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType);
2389823898
}
23899+
return forEach(types, checkGrammarExpressionWithTypeArguments);
23900+
}
23901+
23902+
function checkGrammarExpressionWithTypeArguments(node: ExpressionWithTypeArguments) {
23903+
return checkGrammarTypeArguments(node, node.typeArguments);
2389923904
}
2390023905

2390123906
function checkGrammarClassDeclarationHeritageClauses(node: ClassLikeDeclaration) {

0 commit comments

Comments
 (0)