Remapped generic array type Can't pass to rest parameters #55932
Closed
Description
opened on Oct 1, 2023
🔎 Search Terms
rest parameters tuple array generic
🕗 Version & Regression Information
I tried some versions from 3.3.3 to 5.2.2 and Nightly version 。none of them fixed this problem.
⏯ Playground Link
💻 Code
type Replace<T extends [...any], A, B> = {
[K in keyof T]: T[K] extends A ? B : T[K];
};
type ReplaceParams<T extends [...any],A,B>=(...args:Replace<[number,number],A,B>)=>any;//is ok
type ReplaceParams1<ARRAY extends [...any],A,B>=(...args:Replace<ARRAY,A,B>)=>any;//failed A rest parameter must be of an array type.
type ReplaceParams2<T extends (...arg:any)=>any,A,B>=(...args:Replace<Parameters<T>,A,B>)=>any; //failed A rest parameter must be of an array type.
type Remapped<T extends [...any]> ={
[K in keyof T]:T[K]
}
type SimpleCase<T extends [...any]> = (...args:Remapped<T>)=>any;//failed A rest parameter must be of an array type.
🙁 Actual behavior
this was happend at latest version 5.2.2
and in the next version still no fixed
🙂 Expected behavior
quite sure tuple or array type can be passed to function rest pamaters. but remapped cant.this make replace certain type in parameters inpossible.
Additional information about the issue
No response
Activity