Adding test case

This commit is contained in:
Anders Hejlsberg 2014-12-10 10:17:48 -08:00
parent 7c09b724dc
commit 37b5c74b93
3 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,12 @@
//// [typeGuardsWithAny.ts]
var x: any = { p: 0 };
if (x instanceof Object) {
x.p; // No error, type any is not narrowed
}
//// [typeGuardsWithAny.js]
var x = { p: 0 };
if (x instanceof Object) {
x.p; // No error, type any is not narrowed
}

View file

@ -0,0 +1,17 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts ===
var x: any = { p: 0 };
>x : any
>{ p: 0 } : { p: number; }
>p : number
if (x instanceof Object) {
>x instanceof Object : boolean
>x : any
>Object : ObjectConstructor
x.p; // No error, type any is not narrowed
>x.p : any
>x : any
>p : any
}

View file

@ -0,0 +1,4 @@
var x: any = { p: 0 };
if (x instanceof Object) {
x.p; // No error, type any is not narrowed
}