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
{{ message }}
Repository navigation
Broken narrowing of types intersecting with unique symbols #24846
The compiler reduces empty intersection types to never when used in a union. an empty intersection type is one whose constituents are all unit types. so 1 & 2 "a" & false or "s" & unique symbol.
so PhantomString | null is just null. see #18438 for more details.
Ah ok, I see. Using type PhantomString = string & { "phantom-string": any }; seems to work. I can see there are a few issues suggesting true nominal typing support so I'll add my 👍 to those.
Thanks.
Reacted by Bjørn Zeiler Hougaard and Niklas Lindgren
Activity
jack-williams commentedon Jun 11, 2018
Related #23672 ?
mhegazy commentedon Jun 11, 2018
The compiler reduces empty intersection types to
neverwhen used in a union. an empty intersection type is one whose constituents are all unit types. so1 & 2"a" & falseor"s" & unique symbol.so
PhantomString | nullis justnull. see #18438 for more details.leemhenson commentedon Jun 12, 2018
Ah ok, I see. Using
type PhantomString = string & { "phantom-string": any };seems to work. I can see there are a few issues suggesting true nominal typing support so I'll add my 👍 to those.Thanks.