TS初探

安裝:

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");

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章