Effect of TARGET property inside tsconfig.json

400 Views Asked by At

Below is the tsconfig.json of my project.

{
    "compilerOptions": {
        "module": "commonjs",
        "esModuleInterop": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "target": "es6",
        "noImplicitAny": true,
        "moduleResolution": "node",
        "sourceMap": true,
        "outDir": "dist",
        "baseUrl": ".",
        "typeRoots": [
            "src/types",
            "node_modules/@types",
        ]
    },
    "include": [
        "src/**/*"
    ]
} 

My Typescript version is "typescript": "^3.9.5" and Node version us ts-node": "^8.10.2".

I just want to confirm if i change my target inside tsconfig.json file from "target": "es6" to "target": "es2020"`.How will it effect my current project or i am good.

1

There are 1 best solutions below

0
On BEST ANSWER

TypeScript is a superset of ES6, so you’re essentially writing TS code using ES6 version of JavaScript. However, when compiled, the resulting JS code can be in ES5 or earlier. You need to define which version of JS the compiler should transpile into. This can be set using target option