How do I transpile TypeScript to ES6?

前端 未结 4 696
甜味超标
甜味超标 2020-12-29 03:27

Basically I need to be able to write TypeScript code in my IDE (this introduces great ease to development), compile it to ES6 and then apply babel.js (as all br

4条回答
  •  失恋的感觉
    2020-12-29 03:55

    Yes, You can.

    Either by adding --target es2015, or by adding target to Your tsconfig.json:

    {
      "compilerOptions": {
        "target": "es2015"
      }
    }
    

    Supported options for target are:

    • "ES3" (default)
    • "ES5"
    • "ES6"/"ES2015"
    • "ES2016"
    • "ES2017"
    • "ESNext"

    There are a lot of more config options. You can explore them here: Compiler options

    Some options are only allowed in tsconfig.json, and not through command-line switches.

提交回复
热议问题