Address code review feedback

This commit is contained in:
Anders Hejlsberg 2019-08-05 08:27:54 +02:00
parent fe70a62ef1
commit 1c55e5de69
3 changed files with 16 additions and 14 deletions

View File

@ -1285,7 +1285,8 @@ namespace ts {
}
function isDottedName(node: Expression): boolean {
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression && isDottedName((<PropertyAccessExpression>node).expression);
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.ThisKeyword ||
node.kind === SyntaxKind.PropertyAccessExpression && isDottedName((<PropertyAccessExpression>node).expression);
}
function bindExpressionStatement(node: ExpressionStatement): void {

View File

@ -16838,16 +16838,18 @@ namespace ts {
// that reference function, method, class or value module symbols; or variable, property or
// parameter symbols with declarations that have explicit type annotations. Such references are
// resolvable with no possibility of triggering circularities in control flow analysis.
if (node.kind === SyntaxKind.Identifier) {
const symbol = getResolvedSymbol(<Identifier>node);
return getExplicitTypeOfSymbol(symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol);
}
if (node.kind === SyntaxKind.PropertyAccessExpression) {
const type = getTypeOfDottedName((<PropertyAccessExpression>node).expression);
if (type) {
const prop = getPropertyOfType(type, (<PropertyAccessExpression>node).name.escapedText);
return prop && getExplicitTypeOfSymbol(prop);
}
switch (node.kind) {
case SyntaxKind.Identifier:
const symbol = getResolvedSymbol(<Identifier>node);
return getExplicitTypeOfSymbol(symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol);
case SyntaxKind.ThisKeyword:
return checkThisExpression(node);
case SyntaxKind.PropertyAccessExpression:
const type = getTypeOfDottedName((<PropertyAccessExpression>node).expression);
if (type) {
const prop = getPropertyOfType(type, (<PropertyAccessExpression>node).name.escapedText);
return prop && getExplicitTypeOfSymbol(prop);
}
}
}

View File

@ -3211,6 +3211,7 @@ namespace ts {
const type = parseType();
if (typePredicateVariable) {
const node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typePredicateVariable.pos);
node.assertsModifier = undefined;
node.parameterName = typePredicateVariable;
node.type = type;
return finishNode(node);
@ -3232,9 +3233,7 @@ namespace ts {
const node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate);
node.assertsModifier = parseExpectedToken(SyntaxKind.AssertsKeyword);
node.parameterName = parseIdentifier();
if (parseOptional(SyntaxKind.IsKeyword)) {
node.type = parseType();
}
node.type = parseOptional(SyntaxKind.IsKeyword) ? parseType() : undefined;
return finishNode(node);
}