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
If you hover over Concatenated, you can see that its type is type Concatenated = "a-0" | "a-2" | "a-1" | "b-0" | "b-2" | "b-1" | "c-0" | "c-2" | "c-1".
🙂 Expected behavior
The expected type should instead be type Concatenated = "a-0" | "b-1" | "c-2".
TS doesn't have direct support for correlated unions as described in #30581. The only support is for generics of the form described at #47109, which is kind of yucky for a case like this:
I initially tried to get the result "a-0" | "b-1" | "c-2" with another Playground, though I can see why this other approach gives the wider result "a-0" | "a-2" | "a-1" | "b-0" | "b-2" | "b-1" | "c-0" | "c-2" | "c-1". Is there a way to get the narrower result along the lines of this approach? Or would the solution you shared above be the simplest way to achieve this?
Activity
jcalz commentedon Nov 20, 2024
TS doesn't have direct support for correlated unions as described in #30581. The only support is for generics of the form described at #47109, which is kind of yucky for a case like this:
Playground link
I don't know if this is considered a duplicate of #30581 or a design limitation.
(edit: 🚨❓ 🚑🚔🚒)
regnaio commentedon Nov 20, 2024
Thank you so much for your detailed help, Joe Calzaretta (@jcalz)! 😄
I initially tried to get the result
"a-0" | "b-1" | "c-2"with another Playground, though I can see why this other approach gives the wider result"a-0" | "a-2" | "a-1" | "b-0" | "b-2" | "b-1" | "c-0" | "c-2" | "c-1". Is there a way to get the narrower result along the lines of this approach? Or would the solution you shared above be the simplest way to achieve this?Thank you again!
typescript-bot commentedon Nov 29, 2024
This issue has been marked as "Design Limitation" and has seen no recent activity. It has been automatically closed for house-keeping purposes.