安装:
npm install typescript -g
使用时,新建后缀名为hello.ts的文件,编译时用tsc命令
tsc hello.ts
就可以编译出浏览器可解析的js文件。
热编译步骤:
- 第一步,tsc --init生成tsconfig.json,改"outDir":"./js";
- 第二步,任务=>运行任务=>监视tsconfig.json
第一个实例helloworld:
function helloworld(name: string) {
console.log(`helloworld!${name}`);
return "helloworld";
}
helloworld("zzhiguang");