🔎 Search Terms
"conditional", "distributive", "distribution"
🕗 Version & Regression Information
- This changed between versions 5.3 and 5.4
⏯ Playground Link
https://tsplay.dev/w1GDym
💻 Code
typeobj={foo: 1;bar: 2;};typekeyContaining1<strextendsstring,keysextendskeyofobj=keyofobj,>=keysextends infer keyextendskeyofobj
? keyextends `${string}${str}${string}`
? obj[key]
: never
: never;type_1=keyContaining1<"foo">;// ^? type _1 = 4typekeyContaining2<strextendsstring,keysextendskeyofobj=keyofobj,>=keysextendskeys
? keysextends `${string}${str}${string}`
? obj[keys]
: never
: never;type_2=keyContaining2<"foo">;// ^? type _1 = never🙁 Actual behavior
The value of the generic param collapses to never when an additional conditional is added after the distributive conditional.
The error happens only when distributing with T extends T.
T extends any, T extends unknown, T extends infer U works fine.
🙂 Expected behavior
That the distributive type works similarly to the previous versions.
Additional information about the issue
No response
🔎 Search Terms
"conditional", "distributive", "distribution"
🕗 Version & Regression Information
⏯ Playground Link
https://tsplay.dev/w1GDym
💻 Code
🙁 Actual behavior
The value of the generic param collapses to never when an additional conditional is added after the distributive conditional.
The error happens only when distributing with
T extends T.T extends any,T extends unknown,T extends infer Uworks fine.🙂 Expected behavior
That the distributive type works similarly to the previous versions.
Additional information about the issue
No response