@@ -16852,7 +16852,7 @@ namespace ts {
16852
16852
return !!(declaration && (
16853
16853
declaration.kind === SyntaxKind.VariableDeclaration || declaration.kind === SyntaxKind.Parameter ||
16854
16854
declaration.kind === SyntaxKind.PropertyDeclaration || declaration.kind === SyntaxKind.PropertySignature) &&
16855
- (declaration as VariableDeclaration | ParameterDeclaration | PropertyDeclaration | PropertySignature).type );
16855
+ getEffectiveTypeAnnotationNode (declaration as VariableDeclaration | ParameterDeclaration | PropertyDeclaration | PropertySignature));
16856
16856
}
16857
16857
16858
16858
function getExplicitTypeOfSymbol(symbol: Symbol) {
@@ -16861,11 +16861,11 @@ namespace ts {
16861
16861
getTypeOfSymbol(symbol) : undefined;
16862
16862
}
16863
16863
16864
- function getTypeOfDottedName(node: Expression) {
16865
- // We require the dotted function name in an assertion expression to be comprised of identifiers
16866
- // that reference function, method, class or value module symbols; or variable, property or
16867
- // parameter symbols with declarations that have explicit type annotations. Such references are
16868
- // resolvable with no possibility of triggering circularities in control flow analysis.
16864
+ // We require the dotted function name in an assertion expression to be comprised of identifiers
16865
+ // that reference function, method, class or value module symbols; or variable, property or
16866
+ // parameter symbols with declarations that have explicit type annotations. Such references are
16867
+ // resolvable with no possibility of triggering circularities in control flow analysis.
16868
+ function getTypeOfDottedName(node: Expression): Type | undefined {
16869
16869
switch (node.kind) {
16870
16870
case SyntaxKind.Identifier:
16871
16871
const symbol = getResolvedSymbol(<Identifier>node);
@@ -16874,10 +16874,10 @@ namespace ts {
16874
16874
return checkThisExpression(node);
16875
16875
case SyntaxKind.PropertyAccessExpression:
16876
16876
const type = getTypeOfDottedName((<PropertyAccessExpression>node).expression);
16877
- if (type) {
16878
- const prop = getPropertyOfType(type, (<PropertyAccessExpression>node).name.escapedText );
16879
- return prop && getExplicitTypeOfSymbol(prop);
16880
- }
16877
+ const prop = type && getPropertyOfType (type, (<PropertyAccessExpression>node).name.escapedText);
16878
+ return prop && getExplicitTypeOfSymbol(prop );
16879
+ case SyntaxKind.ParenthesizedExpression:
16880
+ return getTypeOfDottedName((<ParenthesizedExpression>node).expression);
16881
16881
}
16882
16882
}
16883
16883
@@ -16886,7 +16886,9 @@ namespace ts {
16886
16886
let signature = links.effectsSignature;
16887
16887
if (signature === undefined) {
16888
16888
// A call expression parented by an expression statement is a potential assertion. Other call
16889
- // expressions are potential type predicate function calls.
16889
+ // expressions are potential type predicate function calls. In order to avoid triggering
16890
+ // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call
16891
+ // target expression of an assertion.
16890
16892
const funcType = node.parent.kind === SyntaxKind.ExpressionStatement ? getTypeOfDottedName(node.expression) :
16891
16893
node.expression.kind !== SyntaxKind.SuperKeyword ? checkNonNullExpression(node.expression) :
16892
16894
undefined;
0 commit comments