我正在尝试实现这个简单的打字稿代码。但是在通过节点命令运行时出现奇怪的错误。有人可以帮忙吗?
Main.ts
class Wedding {
bond:string;
money:number;
isWeddingPossible() {
if(this.bond === 'Strong' && this.money > 10000 ){
console.log('Wedding can be done.');
}
else{
console.log("Go to hell");
}
}
}
let wedding = new Wedding();
wedding.bond = 'Not Strong';
wedding.money = 500;
wedding.isWeddingPossible();
运行命令: tsc main.ts && node main.ts
错误 :
/ts-hello/main.ts:3
bond:string;
^
SyntaxError: Unexpected token :
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3