Adding test case
This commit is contained in:
parent
7c09b724dc
commit
37b5c74b93
3 changed files with 33 additions and 0 deletions
12
tests/baselines/reference/typeGuardsWithAny.js
Normal file
12
tests/baselines/reference/typeGuardsWithAny.js
Normal 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
|
||||
}
|
17
tests/baselines/reference/typeGuardsWithAny.types
Normal file
17
tests/baselines/reference/typeGuardsWithAny.types
Normal 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
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
var x: any = { p: 0 };
|
||||
if (x instanceof Object) {
|
||||
x.p; // No error, type any is not narrowed
|
||||
}
|
Loading…
Reference in a new issue