api-typings icon indicating copy to clipboard operation
api-typings copied to clipboard

setInterval和setTimeout参数rest只能传一个。如果定时器回掉函数是多个的话,就不行了

Open onlyliujiangtao opened this issue 9 months ago • 0 comments

declare function setInterval(
    /** 回调函数 */
    callback: (...args: any[]) => any,
    /** 执行回调函数之间的时间间隔,单位 ms。 */
    delay?: number,
    /** param1, param2, ..., paramN 等附加参数,它们会作为参数传递给回调函数。 */
    rest?: any
): number
/** [number setTimeout(function callback, number delay, any rest)](https://developers.weixin.qq.com/miniprogram/dev/api/base/timer/setTimeout.html)
 *
 * 设定一个定时器。在定时到期以后执行注册的回调函数 */
declare function setTimeout(
    /** 回调函数 */
    callback: (...args: any[]) => any,
    /** 延迟的时间,函数的调用会在该延迟之后发生,单位 ms。 */
    delay?: number,
    /** param1, param2, ..., paramN 等附加参数,它们会作为参数传递给回调函数。 */
    rest?: any
): number

image

应该改成这样

    /** 回调函数 */
    callback: (...args: any[]) => any,
    /** 延迟的时间,函数的调用会在该延迟之后发生,单位 ms。 */
    delay?: number,
    /** param1, param2, ..., paramN 等附加参数,它们会作为参数传递给回调函数。 */
    ...rest: any

onlyliujiangtao avatar May 24 '24 06:05 onlyliujiangtao