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
By default, conditional types are distributive when given a union type
[1]. However, we don’t actually use anywhere the fact that arrays are
homogeneous, and on the other hand distributive typing forbids
heterogeneous arrays, like an array that contains values and sub-arrays.
Adding square brackets allows heterogeneous arrays without disallowing
homogeneous ones (since `A[]|B[]` is a subtype of `(A|B)[]`).
Add an example demonstrating this – this example doesn’t compile without
my modification, but it does compile with the modification (so it also
functions as a regression test).
[1] https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
0 commit comments