我正在尝试将.ts文件作为控制台应用程序启动。 将.ts文件转换为.js(通过tsc)后,没有错误,但是由于以下问题,我无法使用ts-node启动.ts文件:
“ SyntaxError:意外令牌...”
我的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文件的方式不同。有任何想法吗?谢谢。
答案 0 :(得分:0)
您的tsconfig.json
文件代码中出现拼写错误,
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"esModuleInterpop": rue // here change to true.
}
}
编辑:-
... pieces : IPiece[]
删除并将private
或public
类型添加到此类型。
constructor(public pieces : IPiece[]){ } //use public or private
让我们尝试一次,让我知道。