【发布时间】:2018-12-20 17:13:12
【问题描述】:
我正在尝试将 .ts 文件作为控制台应用程序启动。 将 .ts 文件转换为 .js(通过 tsc)后没有错误,但由于问题,我无法使用 ts-node 启动 .ts 文件:
“SyntaxError: Unexpected token ...”
我的 tsconfig.json 文件是
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"esModuleInterpop": rue
}
}
打字稿代码是
constructor(... pieces : IPiece[]){
super();
for (let i = 0; i < pieces.length; i++) {
this.add(pieces[i]);
}}
所以我猜想 tsc 和 ts-node 编译 .ts 文件的方式不同。有任何想法吗?谢谢。
【问题讨论】:
-
... 件:IPiece[] ?这是什么。
标签: typescript ts-node