microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.08k stars 12.37k forks source link

tsc --init --target es2015 generates es6 tsconfig.json #44144

Open Pike opened 3 years ago

Pike commented 3 years ago

Bug Report

When running tsc --init --target es2015, the generated target is es6.

{
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig.json to read more about this file */

    /* Basic Options */
    // "incremental": true,                         /* Enable incremental compilation */
    "target": "es6"                                 /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
}

This is unfortunate as the generated file looks as if it was having an invalid option.

🔎 Search Terms

tsc init es2015 es6

🕗 Version & Regression Information

I'm using tsc 4.2.4, and replicated with tsc 4.4.0-dev.20210518

🙁 Actual behavior

{
  "compilerOptions": {
    "target": "es6"                                 /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
}

🙂 Expected behavior

{
  "compilerOptions": {
    "target": "es2015"                                 /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
}
RyanCavanaugh commented 3 years ago

These are interchangeable and it doesn't matter which you put here. Would be OK with a PR if it's not too complicated.