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
{{ message }}
Repository navigation
Each tuple member type becomes union of all tuple member types when intersection with object #53091
I'm attempting to define a Row type which has a generic being an array of pair tuples, like a Map's entries 2d array, that is a tuple of the mapped value members (index 1), of each pair intersected with an object of the key: value members.
// We can quickly address your report if:// - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!// - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.// - The incorrectness of the behavior is readily apparent from reading the sample.// Reports are slower to investigate if:// - We have to pare too much extraneous code.// - We have to clone a large repo and validate that the problem isn't elsewhere.// - The sample is confusing or doesn't clearly demonstrate what's wrong.
🙁 Actual behavior
foo_0 is a number|string & foo_1 is a number|string.
🙂 Expected behavior
foo_0 should be a number & foo_1 should be a string.
I believe that the tuple position type behavior should be preserved when intersected with another type.
changed the title [-]Tuple value types become union of all tuple value types when intersected with an object[/-][+]Each tuple member type becomes union of all tuple member types when intersected with an object[/+]on Mar 5, 2023
changed the title [-]Each tuple member type becomes union of all tuple member types when intersected with an object[/-][+]Each tuple member type becomes union of all tuple member types when intersection with object[/+]on Mar 5, 2023
Activity
Seally commentedon Mar 4, 2023
Your playground link uses the type
TupleToObject, which doesn't exist, and there's an extra)in the type parameters ofRowandRowTuple.I changed
TupleToObjecttoTupleToProps(I assume that's the intention), and removed the extra)and I think it works now?btakita commentedon Mar 4, 2023
Sorry about that. I updated the Playground Link in the OP description as well.
[-]Tuple value types become union of all tuple value types when intersected with an object[/-][+]Each tuple member type becomes union of all tuple member types when intersected with an object[/+][-]Each tuple member type becomes union of all tuple member types when intersected with an object[/-][+]Each tuple member type becomes union of all tuple member types when intersection with object[/+]RyanCavanaugh commentedon Mar 6, 2023
Using the example from that link but adding
exportto show the types:the .d.ts shows all as-expected
Can you clarify?