What causes Exclude<A,B>
to resolve to the never
type in the code snippet below? Shouldn't the typescript compiler be able to infer (through static analysis) that A
and B
are extending Parent
, leading to Exclude<Choices, Parent>
resolving to type C
?
interface Parent {}
interface A extends Parent {}
interface B extends Parent {}
interface C {}
type Choices = A | B | C
type Test = Exclude<Choices, Parent> // = type "never"???
const c: C = {}
const d: Test = c // Type 'C' is not assignable to type 'never'
One possible workaround is to manually set Parent = A | B
, but the necessity of this step remains unclear.