第一次使用TS。一个很简单的语句就报错,就是给常量加了个类型。
string及 {x:number,y:number}及{x:number}都会报错的
const greeting:string="abc";
const temp:{x:number,y:number}={x:5,y:6};
console.log(temp);
//@ts-ignore
const point:{x:number}={x:88};
console.log(point);
报错信息:
C:\Program Files\nodejs\node.exe .\hello-world.ts
Process exited with code 1
Uncaught SyntaxError d:\VUE-test\typescript_tt\hello-world.ts:1
const greeting:string="abc";
^
SyntaxError: Missing initializer in const declaration
at compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Module._load (node:internal/modules/cjs/loader:822:12)
at executeUserEntryPoint (node:internal/modules/run_main:77:12)
at (node:internal/main/run_main_module:17:47)
没有可用的调试程序,无法发送“variables”