mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Parser changes to parse omitted types correctly
This commit is contained in:
@@ -1078,7 +1078,7 @@ module ts {
|
||||
return isParameter();
|
||||
case ParsingContext.TypeArguments:
|
||||
case ParsingContext.TupleElementTypes:
|
||||
return isType();
|
||||
return token === SyntaxKind.CommaToken || isType();
|
||||
}
|
||||
|
||||
Debug.fail("Non-exhaustive case in 'isListElement'.");
|
||||
@@ -2344,13 +2344,24 @@ module ts {
|
||||
function parseTypeArguments(): NodeArray<TypeNode> {
|
||||
var typeArgumentListStart = scanner.getTokenPos();
|
||||
var errorCountBeforeTypeParameterList = file.syntacticErrors.length;
|
||||
var result = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken);
|
||||
var result = parseBracketedList(ParsingContext.TypeArguments, parseSingleTypeArgument, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken);
|
||||
if (!result.length && file.syntacticErrors.length === errorCountBeforeTypeParameterList) {
|
||||
grammarErrorAtPos(typeArgumentListStart, scanner.getStartPos() - typeArgumentListStart, Diagnostics.Type_argument_list_cannot_be_empty);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseSingleTypeArgument(): TypeNode {
|
||||
if (token === SyntaxKind.CommaToken) {
|
||||
var errorStart = scanner.getTokenPos();
|
||||
var errorLength = scanner.getTextPos() - errorStart;
|
||||
grammarErrorAtPos(errorStart, errorLength, Diagnostics.Type_expected);
|
||||
return createNode(SyntaxKind.OmittedType);
|
||||
}
|
||||
|
||||
return parseType();
|
||||
}
|
||||
|
||||
function parsePrimaryExpression(): Expression {
|
||||
switch (token) {
|
||||
case SyntaxKind.ThisKeyword:
|
||||
|
||||
Reference in New Issue
Block a user