TypeScript Compilation Options: Module vs. Target

Trying to have a basic understanding of the module and purpose.

I would like to know the difference between the compilation options of the module and the target in a typical tsconfig.json

  {
     "compilerOptions": {
         "module": "es6",
         "sourceMap": true,
         "target": "es6"
     }
 }

What happens if I provide the following options:

module: commonjs, target: es6

module: es6, target: commonjs

module: commonjs, target: commonjs

+6
source share
1 answer

From the documentation on the compiler options :

- target

Specify the target version of ECMAScript: "es3" (default), "es5" or "es6".

- module

Define the module code generation: "none", "commonjs", "amd", "system", "umd", "es6" or "es2015".

  • Only "amd" and "system" can be used with --outFile.
  • 'es6' and 'es2015' cannot be used when configuring ES5 or lower.

See also: ES6 in depth: Modules .

+1
source

All Articles