Description
Bug Report
π Search Terms
tuple type spread, symbol iterator spread
π Version & Regression Information
- This changed between versions 4.6.4 and 4.7.4
β― Playground Link
π» Code
type Mapped<T extends any[]> = { [ P in keyof T ] : T[P] }
function fn<T extends (...args: any[]) => any>(cb: T, ...rest: Mapped<Parameters<T>>): ReturnType<T> {
return cb(...rest);
// ^?
}
π Actual behavior
The code failed to compile with the error
Type 'Mapped<Parameters>' must have a 'Symbol.iterator' method that returns an iterator.
π Expected behavior
Prior to 4.7.4 this compiled. I included the types "paramsOfTest" and "paramsOfNone" to demonstrate that the resulting types do evaluate to tuples, even without any parameters. It seems to me that the type should always evaluate to an iterable tuple since the "Parameters" type should evaluate to a tuple and the types ReplaceIndexWithUndefined and FilterUndefined should also evaluate to iterable types due to their type constraints.
Edited to use the simpler repro from comments to simplify.
Given that this was working previously and I was not able to find more information I assumed this was a bug but I apologize if I have missed something.