Merge pull request #8443 from Microsoft/controlFlowAccessors

Include accessors in control flow type analysis
This commit is contained in:
Anders Hejlsberg
2016-05-03 16:11:15 -07:00
3 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -9795,7 +9795,7 @@ namespace ts {
}
const propType = getTypeOfSymbol(prop);
if (node.kind !== SyntaxKind.PropertyAccessExpression || !(prop.flags & (SymbolFlags.Variable | SymbolFlags.Property)) || isAssignmentTarget(node)) {
if (node.kind !== SyntaxKind.PropertyAccessExpression || !(prop.flags & (SymbolFlags.Variable | SymbolFlags.Property | SymbolFlags.Accessor)) || isAssignmentTarget(node)) {
return propType;
}
const leftmostNode = getLeftmostIdentifierOrThis(node);
@@ -57,18 +57,18 @@ class C1 {
>pp2 : string
strOrNum = typeof this.pp3 === "string" && this.pp3; // string | number
>strOrNum = typeof this.pp3 === "string" && this.pp3 : string | number
>strOrNum = typeof this.pp3 === "string" && this.pp3 : string
>strOrNum : string | number
>typeof this.pp3 === "string" && this.pp3 : string | number
>typeof this.pp3 === "string" && this.pp3 : string
>typeof this.pp3 === "string" : boolean
>typeof this.pp3 : string
>this.pp3 : string | number
>this : this
>pp3 : string | number
>"string" : string
>this.pp3 : string | number
>this.pp3 : string
>this : this
>pp3 : string | number
>pp3 : string
}
}
var c1: C1;
@@ -90,18 +90,18 @@ strOrNum = typeof c1.pp2 === "string" && c1.pp2; // string | number
>pp2 : string
strOrNum = typeof c1.pp3 === "string" && c1.pp3; // string | number
>strOrNum = typeof c1.pp3 === "string" && c1.pp3 : string | number
>strOrNum = typeof c1.pp3 === "string" && c1.pp3 : string
>strOrNum : string | number
>typeof c1.pp3 === "string" && c1.pp3 : string | number
>typeof c1.pp3 === "string" && c1.pp3 : string
>typeof c1.pp3 === "string" : boolean
>typeof c1.pp3 : string
>c1.pp3 : string | number
>c1 : C1
>pp3 : string | number
>"string" : string
>c1.pp3 : string | number
>c1.pp3 : string
>c1 : C1
>pp3 : string | number
>pp3 : string
var obj1: {
>obj1 : { x: string | number; }
@@ -172,16 +172,16 @@ strOrNum = typeof obj1.method(strOrNum) === "string" && obj1.method(strOrNum);
// accessing getter property
strOrNum = typeof obj1.prop === "string" && obj1.prop;
>strOrNum = typeof obj1.prop === "string" && obj1.prop : string | number
>strOrNum = typeof obj1.prop === "string" && obj1.prop : string
>strOrNum : string | number
>typeof obj1.prop === "string" && obj1.prop : string | number
>typeof obj1.prop === "string" && obj1.prop : string
>typeof obj1.prop === "string" : boolean
>typeof obj1.prop : string
>obj1.prop : string | number
>obj1 : { method(param: string | number): string | number; prop: string | number; }
>prop : string | number
>"string" : string
>obj1.prop : string | number
>obj1.prop : string
>obj1 : { method(param: string | number): string | number; prop: string | number; }
>prop : string | number
>prop : string