How to transpile TypeScript to ES6?

Sometimes, we want to transpile TypeScript to ES6.

In this article, we’ll look at how to transpile TypeScript to ES6.

How to transpile TypeScript to ES6?

To transpile TypeScript to ES6, we can set the compilerOptions.target option to 'es2015' in tsconfig.json.

For instance, we write

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

into tsconfig.json to make the TypeScript compiler build our code to ES6 JavaScript code.

Conclusion

To transpile TypeScript to ES6, we can set the compilerOptions.target option to 'es2015' in tsconfig.json.