Skip to content

Commit 982ab1f

Browse files
committed
Fix grammar check for empty type argument list and compiler crash
1 parent bdaeb63 commit 982ab1f

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
@@ -4827,7 +4827,7 @@ namespace ts {
48274827

48284828
function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[], location: Node): Signature[] {
48294829
let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
4830-
if (typeArgumentNodes) {
4830+
if (some(typeArgumentNodes)) {
48314831
const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode);
48324832
signatures = map(signatures, sig => getSignatureInstantiation(sig, typeArguments));
48334833
}
@@ -20927,7 +20927,7 @@ namespace ts {
2092720927
const staticBaseType = getApparentType(baseConstructorType);
2092820928
checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
2092920929
checkSourceElement(baseTypeNode.expression);
20930-
if (baseTypeNode.typeArguments) {
20930+
if (some(baseTypeNode.typeArguments)) {
2093120931
forEach(baseTypeNode.typeArguments, checkSourceElement);
2093220932
for (const constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode)) {
2093320933
if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) {
@@ -23910,6 +23910,11 @@ namespace ts {
2391023910
const sourceFile = getSourceFileOfNode(node);
2391123911
return grammarErrorAtPos(sourceFile, types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType);
2391223912
}
23913+
return forEach(types, checkGrammarExpressionWithTypeArguments);
23914+
}
23915+
23916+
function checkGrammarExpressionWithTypeArguments(node: ExpressionWithTypeArguments) {
23917+
return checkGrammarTypeArguments(node, node.typeArguments);
2391323918
}
2391423919

2391523920
function checkGrammarClassDeclarationHeritageClauses(node: ClassLikeDeclaration) {

0 commit comments

Comments
 (0)