Non-homomorphic instantiation of a homomorphic mapped type is not spreadable when it has an array constraintΒ #56726
Description
opened on Dec 10, 2023
π Search Terms
mapped type homomorphic instantiation array tuple constraint spread spreadable
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
type HandleOptions<O> = {
[I in keyof O]: {
value: O[I];
};
};
declare function func1<
T extends Record<PropertyKey, readonly any[]>,
>(fields: {
[K in keyof T]: {
label: string;
options: [...HandleOptions<T[K]>];
};
}): T;
const result = func1({
prop: {
label: "first",
options: [
{
value: 123,
},
{
value: "foo",
},
],
},
other: {
label: "second",
options: [
{
value: "bar",
},
{
value: true,
},
],
},
});
π Actual behavior
Error at line 12:
A rest element type must be an array type.(2574)
π Expected behavior
The error should not be reported
Additional information about the issue
No response
Activity