mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 22:51:17 -05:00
Adding test case
This commit is contained in:
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
|
||||
}
|
||||
Reference in New Issue
Block a user