mac webstorm自動編譯typescript配置


 

1、安裝typescrip

npm install -g typescript    

                                                                                              

2、在typescript文件所在目錄中打開terminal輸入tsc --init安裝tsconfig.js

tsc --init

3、編輯tscongfig.json,修改outDir的參數,既默認ts轉換成js后的輸出目錄

 

 

 4、點擊webStorm->Preferences到設置頁面

 

5、點擊tools->File Watchers->左下角的+號、選擇custom

 

 

 

 

 

 

 6、輸入如下信息

Name:TypeScript
File Type:TypeScript
Scope:All Places
Program:/usr/local/lib/node_modules/typescript/bin/tsc(既安裝typescript的路徑下的tyc文件)
Arguments:--sourcemap --target "ES5"
Output paths to refresh:$FileNameWithoutExtension$.js:$FileNameWithoutExtension$.js.map
WOrking directory:$FileDir$

 

 

 點擊ok->Apply完成。

再次編輯ts文件就會自動編譯為js了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM