You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceA{value: number|string};interfaceB{value: number;}functiontakeOnlyB(value: B): void{}constdata: A={value: 'hey'};data.value=1;// <-- from this point on we know for sure that value is numbertakeOnlyB(data);// <-- problem, despite effectively being of type `B` data still can't be used// expected: takeOnlyB should accept data because it's been asserted to comply with `B`
Argument of type 'A' is not assignable to parameter of type 'B'.
Types of property 'value' are incompatible.
Type 'string | number' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
The text was updated successfully, but these errors were encountered:
zpdDG4gta8XKpMCd
changed the title
allow an object narrowed a certain interface be used where such interface is expected
allow an object narrowed to a certain interface be used where such interface is expected
Dec 14, 2016
The text was updated successfully, but these errors were encountered: