-
Couldn't load subscription status.
- Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
Hi!
Type narrowing is not working (not supported?) for fields (VS2013, TypeScript 1.4).
class O1Cls {
x: any;
}
class O2Cls {
y: any;
}
interface Options {
opt: O1Cls|O2Cls;
}
class MyClass {
constructor(options: Options) {
if (options.opt instanceof O1Cls) {
console.log(options.opt.x); // Error: Property 'x' does not exists on type 'O1Cls | O2Cls'
}
var opt = options.opt;
if (opt instanceof O1Cls)
{
console.log(opt.x); // OK
}
}
}Will it be supported or is this a "by design" behaviour?
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created