Microsoft/TypeScript
GitHub ã§èŠãts2556 is too restrictive when generics are involved
Open
#57,322 opened on 2024幎2æ7æ¥
Domain: check: Type InferenceHelp WantedPossible Improvement
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
"generic", "tuple", "spread", "rest", "ts2556", "a spread argument must either have a tuple type or be passed to a rest parameter"
ð Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about spreading into argument lists
⯠Playground Link
ð» Code
declare const f: () => void
declare const x: readonly []
f(...x) // works
const test = <T extends readonly []>(x: T) =>
f(...x) // does not work
ð Actual behavior
Attempting to spread a generically-typed value whose constraint guarantees tuple-ness into a compatible argument list is forbidden.
ð Expected behavior
I should be allowed to do this.
Additional information about the issue
Possibly-related issues: