Address comments

This commit is contained in:
Nathan Shively-Sanders 2015-12-08 14:11:46 -08:00
parent a4e21d7858
commit f9846ff2bc

View File

@ -2538,13 +2538,11 @@ namespace ts {
}
function parseTypeOrTypePredicate(): TypeNode {
const typePredicateVariable = tryParse(() => {
const id = parseIdentifier();
if (token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
nextToken();
return id;
}
});
let typePredicateVariable: Identifier;
if (isIdentifier()) {
typePredicateVariable = tryParse(parseTypePredicatePrefix);
}
const type = parseType();
if (typePredicateVariable) {
const node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typePredicateVariable.pos);
@ -2557,6 +2555,14 @@ namespace ts {
}
}
function parseTypePredicatePrefix() {
const id = parseIdentifier();
if (token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
nextToken();
return id;
}
}
function parseType(): TypeNode {
// The rules about 'yield' only apply to actual code/expression contexts. They don't
// apply to 'type' contexts. So we disable these parameters here before moving on.