#Variable doesn't had properties although it does

5 messages · Page 1 of 1 (latest)

warm sequoia
#

Guys
Let's assume that you have this line of code:

const foo:bar | void = foobar;

Type script won't make you use the properties of bar on foo because it doesn't exist on void, as it claims.
How can I fix this?
Assuming that bar is an object that has properties and foobar is an instance of bar

azure bluff
#

what if you use undefined instead of void?

tepid plaza
warm sequoia
azure bluff
#

I didn’t get the issue here. If you have a type guard or just a if(foo) then foo will be inferred as only bar