【问题标题】:Simple TypeScript spread not working?简单的 TypeScript 传播不起作用?
【发布时间】:2017-01-16 17:15:08
【问题描述】:

我是 TypeScript 新手,如果我犯了错误,请多多包涵。

根据在线 TypeScript 指南this,以下 TypeSript 是有效的:

function foo(x, y, z) { }
var args = [0, 1, 2];
foo(...args);

相反,当我运行 tsc *.ts --watch --target ES6 来编译我的 TypeScript 时,我得到了 error TS2346: Supplied parameters do not match any signature of call target.

这不应该很好吗?这是一项相当基本的任务,那我做错了什么?

【问题讨论】:

标签: typescript tsc


【解决方案1】:

你可以试试这个代码there

function foo(x:number, y:number, z:number):void {
	console.log(x,y,z);
}
let args:number[] = [0, 1, 2];
foo(...args);

强文本

【讨论】:

    猜你喜欢
    • 2016-09-11
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-07
    • 2016-06-21
    • 2015-10-10
    • 1970-01-01
    相关资源
    最近更新 更多