Open RobertBouillon opened 2 months ago
Thanks for the report!
This should also function as a workaround:
if y is string or y is Foo then
Thanks for the report!
This should also function as a workaround:
if y is string or y is Foo then
I like that better, thanks!
Incredible library, by the way. Takes a lot of the sting out of large Lua scripts, especially coming from C#, Java, and TS.
Type guards with unions that include a record (table) will only check for the table. Other values included in the union will not be captured.
Workaround
You can add a manual type guard in place of the union, which then gets inferred, but only if: 1) it's in an
elseif
block and 2) theif
statement starts with anis
expression