- Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 2.2.0-dev.20170113
Code
class test1 { someProp; } class test2 { anotherProp; } let myTest: test1 | test2; if (myTest instanceof test1) { // valid myTest.someProp; // invalid, someProp does not exist on type 'test2' () => myTest.someProp; // meaning if you have a eg. forEach [].forEach(() => { // you will need an instance check here too // invalid myTest.someProp; // valid if (myTest instanceof test1) myTest.someProp; }) }
Expected behavior:
I expected typescript to know myTest was instanceof test1 inside the function. It did not give these errors in typescript 1.8
Actual behavior:
It lost this knowledge inside the function.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created