mac webstorm 使用typescript 和配置自动编辑

本文介绍了在Mac环境下如何在WebStorm中安装和配置TypeScript,包括通过npm安装、生成和配置tsconfig.js文件,以及调整WebStorm的设置以实现自动编译。详细步骤包括修改tsconfig的outDir参数,设置编译输出目录,以及在WebStorm中设置File Watchers以实现文件变动时自动编译为JS。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装typescript

打开终端 使用npm的前提是安装了node

npm install -g typescript

配置tsconfig.js(ts配置文件)

在所要编译的ts所在的目录中打开终端 输入tsc --init ,可以自动生成tsconfig.js

tsc --init

配置tsconfig文件

{
   
  "compilerOptions": {
   
    /* Basic Options */
    // "incremental": true,                   /* Enable incremental compilation */
    "target": "es5",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
    // "lib": [],                             /* Specify library files to be included in the compilation. */
    // "allowJs": true,                       /* Allow javascript files to be compiled. */
    // "checkJs": true,                       /* Report errors in .js files. */
    // "jsx": "preserve",                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
    // "declaration": true, 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值