Simplify parseTypeReference

Create the node first, rather than creating it later and setting its pos to another node that was created first.
This commit is contained in:
Andy Hanson 2017-04-04 13:55:47 -07:00
parent 1c649433bd
commit 2d3dd85632

View file

@ -2054,9 +2054,8 @@ namespace ts {
// TYPES
function parseTypeReference(): TypeReferenceNode {
const typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
const node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference, typeName.pos);
node.typeName = typeName;
const node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference);
node.typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
if (!scanner.hasPrecedingLineBreak() && token() === SyntaxKind.LessThanToken) {
node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken);
}