1

Why is the result here

type result = (1 | 1 | 2) extends 1 ? 3 : 4

4?

Should not result be 3 | 4 ?

Because I thought above is same as: (1 extends 1 ? 3 : 4) | (1 extends 1 ? 3 : 4) | (2 extends 1 ? 3 : 4) = 3 | 3 | 4. No?

  • distribution only happens on generic types. `(1 | 1 | 2)` is not a generic type – Tobias S. Nov 19 '22 at 22:16
  • `(1 | 1 | 2)` is not a naked type parameter, therefore this is not a distributive conditional type; it is just a conditional type. – kaya3 Nov 19 '22 at 22:16
  • @kaya3 I will check this but what would result be here `type AnyOf = T[number] extends false ? false: true ` if say there are two `false` values and two `true` values in the `T` array? –  Nov 19 '22 at 22:20
  • `T[number]` is also not a naked type parameter; it is an indexed access type. – kaya3 Nov 19 '22 at 23:11

0 Answers0