Relative Content

Tag Archive for typescripttuplescovarianceunion-typessubtyping

Why is [1 | 2] not a subtype of [1 | []] | [2 | []] in TypeScript?

In TypeScript, I have an API whose input is a union of tuples and I have a value whose type is a tuple of unions that I want to pass into it. It seems like this works in most cases, but I can’t figure out why it doesn’t work in my case, and what I can do to get it to work without needing a type assertion. Here is a reproduction of the issue (TS Playground link):