【发布时间】:2021-06-02 01:32:10
【问题描述】:
我写了这段代码:
type SomeOptions = {
a: string;
};
type SomeMethod<T extends any[]> = (
...args: [...T, otherOptions: SomeOptions]
) => void;
但 TypeScript 检查器会抛出错误:“元组成员必须都具有名称或都没有名称。”
那么如何将T 定义为命名元组?
【问题讨论】:
标签: typescript typescript-typings typescript-generics