【发布时间】:2014-01-12 16:43:43
【问题描述】:
在 TypeScript 中,可以使用“Rest Parameters”声明函数:
function test1(p1: string, ...p2: string[]) {
// Do something
}
假设我声明了另一个名为 test1 的函数:
function test2(p1: string, ...p2: string[]) {
test1(p1, p2); // Does not compile
}
编译器产生这条消息:
提供的参数与调用目标的任何签名都不匹配: 无法将类型“字符串”应用于“字符串 []”类型的参数 2。
test2 如何调用test1 将提供的参数?
【问题讨论】:
标签: typescript