💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
起初编写完TypeScript后是在命令行工具下编译ts文件,后来发现ts文件内容一旦发生改变就要手动去执行编译命令,难免降低了工作效率。后来发现原来强大的Webstorm IDE也可以开发TypeScript,还支持自动编译成js文件。 下面说一下完整的设置步骤吧 1.去node.js官网下载安装node.js 2.下载安装新版本的Webstorm 3.使用node的npm命令安装typeScript编译器 npm install typescript -g 安装好,在命令行可以查看编译器的版本 tsc -v 4.打开Webstorm,新建一个空白项目,命名为TypeScriptPro\_01 ![](//upload-images.jianshu.io/upload_images/5613607-927941b9e23d8b98.png?imageMogr2/auto-orient/strip|imageView2/2/w/797/format/webp) 5.在Webstorm中右击项目名,选择new->tsconfig.json File,创建tsconfig.json文件 ![](//upload-images.jianshu.io/upload_images/5613607-4b1e96b1acffae48.png?imageMogr2/auto-orient/strip|imageView2/2/w/812/format/webp) 6.打开Webstorm,为TypeScript文件更改编译设置,File->Settings->File Watchers->TypeScript,这里我们需要选择TypeScript,但是 File Watchers下默认是不存在的。需要点击右侧“+”号,选择,弹出 New Watcher,设置好圈红线的部分,点击ok。勾 选“TypeScript”,点击ok。 ![](//upload-images.jianshu.io/upload_images/5613607-e72f99c33bef743f.png?imageMogr2/auto-orient/strip|imageView2/2/w/1174/format/webp) ![](//upload-images.jianshu.io/upload_images/5613607-bfd5ba6a9812eb2d.png?imageMogr2/auto-orient/strip|imageView2/2/w/637/format/webp) ``` Program:D:\\tools\\Ionic\\nodejs\\tsc.cmd Arguments:--sourcemap --target "ES5" Output paths to refresh:$FileNameWithoutExtension$.js:$FileNameWithoutExtension$.js.map Working directory:$FileDir$ ``` 7.设置typescript自动编译,勾选下图圈红线的位置。 ![](//upload-images.jianshu.io/upload_images/5613607-ab2cc3542c285661.png?imageMogr2/auto-orient/strip|imageView2/2/w/1037/format/webp) 这样,typescript的自动编译功能就设置好了,测试一下,很带劲,你只需要负责写ts就好了,的确方便了很多。 ![](//upload-images.jianshu.io/upload_images/5613607-fb86939068b295cf.png?imageMogr2/auto-orient/strip|imageView2/2/w/928/format/webp) 作者:Arvin627 链接:https://www.jianshu.com/p/310eaba45d99 来源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。