我有一个简单的打字稿功能。
function disp_details(id:number,name:string,mail_id?:string) {
console.log("ID:", id);
console.log("Name",name);
if(mail_id!=undefined)
console.log("Email Id",mail_id);
}
disp_details(123,"John");
disp_details(111,"mary","mary@xyz.com");
当我尝试在Vs代码中运行该函数时,出现错误。 C:\ Apps \ TypeScript-Test>节点Script-4.ts
C:\ Apps \ TypeScript-Test \ Script-4.ts:1 (函数(导出,需求,模块,__ filename,__ dirname){函数disp_details(id:number,name:string,mail_id?:string){
SyntaxError: Unexpected token :
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at vs coderap_node.js:612:3
我正在使用vscode,无法解决问题。