Closed
Description
TypeScript Version: (2.0.0-beta)
Code
interface Test1 {
type: 'test1'
label: 'string'
}
interface Test2 {
type: 'test2'
}
let a: Test1 | Test2
if (a.type == 'test1') {
console.log(a.label) // works ok
setTimeout(()=>{
console.log(a.label) // Error: Property 'label' does not exist on type 'Test1 | Test2'
})
}
Expected behavior:
setTimeout case should work ?
Actual behavior:
Error: Property 'label' does not exist on type 'Test1 | Test2'
in setTimeout