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
typeFoo<K,Textendsreadonlyunknown[]>=Textendsreadonly[any, ...infer Xextendsreadonlyunknown[]] ? X : never;typeBar<K,Textendsreadonlyunknown[]>=Textendsreadonly[any, ...infer XextendsreadonlyK[]] ? X : never;typeBaz<K,Textendsreadonlyunknown[]>=Textendsreadonly[any, ...infer Xextendsreadonly(K|"a"|"b")[]] ? X : never;typex=Foo<"a"|"b",["a","b","b"]>// ^? - type x = ["b", "b"]typey=Bar<"a"|"b",["a","b","b"]>// ^? - type y = readonly ("a" | "b")[]typez=Baz<"a"|"b",["a","b","b"]>// ^? - type z = ["b", "b"]
π Actual behavior
The conditional types do not produce the same output:
Alternatively if that is infeasible for technical reasons, the conditional type should fail. Inferring the constraint makes traversing the tuple impossible.
The text was updated successfully, but these errors were encountered:
Bug Report
π Search Terms
conditional type, extends, infer, spread, tuple
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The conditional types do not produce the same output:
π Expected behavior
The conditional types should all produce the same output. The fact that
K
is a type parameter should not affect the output.Alternatively if that is infeasible for technical reasons, the conditional type should fail. Inferring the constraint makes traversing the tuple impossible.
The text was updated successfully, but these errors were encountered: