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
Expected behavior:
This pattern is very common in javascript, that would be great to make it valid in typescript.
Actual behavior:
Property 'foo' does not exist on type 'Foo | Bar'.
Property 'foo' does not exist on type 'Bar'.
Property 'bar' does not exist on type 'Foo | Bar'.
Property 'bar' does not exist on type 'Foo'.
The text was updated successfully, but these errors were encountered:
That would make the type system unsound. Doing so would cause all sorts of bad code.
You need to understand better how the typing system works. When you have a Schrödinger's cat type like that, TypeScript will only allow you to access the properties it knows are in common. If you wanted it to work, you could change the type:
TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
Code
Expected behavior:
This pattern is very common in javascript, that would be great to make it valid in typescript.
Actual behavior:
The text was updated successfully, but these errors were encountered: