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
The issue here is that A & B is an empty intersection (i.e. a type for which you couldn't possibly construct a value) that now reduces to never. We previously didn't catch such types.
Yes, but any type that includes a property of type never is a type with no possible values, so we're not talking about something that couldn't exist in the real world. Ideally we'd reduce all such types to never (that is, instead of { my: never } we'd simply have never) but it is costly to check for and tricky to do in a lazily evaluated type system.
Activity
kitsonk commentedon May 13, 2020
Effectively duplicate of #38241, related to breaking change #37195.
ahejlsberg commentedon May 14, 2020
The issue here is that
A & Bis an empty intersection (i.e. a type for which you couldn't possibly construct a value) that now reduces tonever. We previously didn't catch such types.You could instead write your code as
That is, omit the conflicting discriminants before you intersect the types.
zombieJ commentedon May 14, 2020
Anders Hejlsberg (@ahejlsberg) , but never can be omit:
https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=8&pc=1#code/JYOwLgpgTgZghgYwgAgILIN7ILAChnIC2AngFzIgQBu0A3HgL556iSyIoDCyEAHpCAAmAZ2QB5QsDAAeVABpkAchKKAfJhz4iZZMLBRQAc3q4muIA
ahejlsberg commentedon May 14, 2020
Yes, but any type that includes a property of type
neveris a type with no possible values, so we're not talking about something that couldn't exist in the real world. Ideally we'd reduce all such types tonever(that is, instead of{ my: never }we'd simply havenever) but it is costly to check for and tricky to do in a lazily evaluated type system.typescript-bot commentedon May 16, 2020
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.