In the code below
const f = <
Args extends any[] = never
>(...args: Args) => {
const foo: [number, number, ...Args] = [0, 0, ...args]
}
tsc does not like [number, number, ...Args]
even though I thought I was constraining the type to be an array with Args extends any[]
i get this error
A rest element type must be an array type
type Args = any[];
const f = (...args: Args) => {
const foo: [number, number, ...Args] = [0, 0, ...args]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.