Skip to content

Non-homomorphic instantiation of a homomorphic mapped type is not spreadable when it has an array constraint #56726

Description

🔎 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

https://www.typescriptlang.org/play?ts=5.4.0-dev.20231210#code/C4TwDgpgBAEghgOwCYBsIHkzAJYHsEDOAPOgHxQC8UA3gLABQUUA2gJJTYJQDWEIuAMyjoAugC4aDJkwBucFAFcIE9GxEBuKVAC+m+roYMkEAMYo4AJ2gCFCEznxQbdgIxEtAFSgQAHsAjIBFAASqa4FkhEAAoWuJAWoADSfAA0UFZwSPgoIFCIIMwipCkMpAAUAtgQKEgEEnSMLIkcXLz8Qh7iko1M5gBG1RIEwBacAOZ60lBxDoQSzAB0S-DIaJizxB7MiUUaWgb6AJQSHnoMJvjD6RAECijAlE62Ji5lDUxgsWD1Wr1wAygJAAiSoWYZAko9aZYPBzFi-aTvKbSOSKZRQFwAJgAzJDkTo8cikfjUUpgQJcLgIQimNpCUwRIS6VpcMAABYQCw-KH9QZQIEEMLIalQmawurwqFMYnI0nooF9Swi-HMqXdfGyeRkqAjJT06SqqaM-aQ7SHPRAA

💻 Code

typeHandleOptions<O>={[IinkeyofO]: {value: O[I];};};declarefunctionfunc1<TextendsRecord<PropertyKey,readonlyany[]>,>(fields: {[KinkeyofT]: {label: string;options: [...HandleOptions<T[K]>];};}): T;constresult=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

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions