【发布时间】:2021-09-02 14:59:01
【问题描述】:
我有以下函数,它接受任意数量的参数。但是,我知道第一个参数必须是一个函数,其他参数可以是任何东西,我不知道数组的长度。 我应该为已知第一个元素但未知长度和其他类型的数组类型赋予什么形状?
// i tried also ...args: [Function, any], but eslint does not like the generic 'Function' type and throw an error
function test(...args: Array<????>) {
const [callbackFn, ...restOfArgs] = args;
// do whatever
}
【问题讨论】:
标签: typescript