Linked Questions

Popular Questions

tsconfig target set to es5 but still uses let & const

Asked by At

I am trying to use UglifyJS on code generated by tsc.

The target is set to es5 but the generated code still uses let & const declarations (no idea why because they are not in the ES5 spec) hence uglifyjs keep crying about it.

Does anyone know how can I make tsc use var instead of let & const? (Targeting es3 is not an option)

Here is the current tsconfig file:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "target": "es6",
    "noImplicitAny": false,
    "noUnusedParameters": true,
    "noUnusedLocals": true,
    "strictNullChecks": true,
    "sourceMap": true,
    "declaration": true,
    "noEmitHelpers": true,
    "importHelpers": true,
    "outDir": "lib",
    "pretty": true,
    "lib": [
      "es2015",
      "es2016",
      "es2017",
      "dom"
    ],
    "jsx": "react",
    "types": [
      "webpack",
      "webpack-env",
      "jest"
    ]
  },
  "compileOnSave": false,
  "exclude": [
    "node_modules",
    ".tmp",
    "lib",
    "e2e/**"
  ],
  "include": [
    "./custom.d.ts",
    "./demo/playground/hmr-playground.tsx",
    "./src/**/*.ts?",
    "demo/*.tsx"
  ]
}

Related Questions