简体   繁体   English

tsconfig.json 中 TARGET 属性的影响

[英]Effect of TARGET property inside tsconfig.json

Below is the tsconfig.json of my project.下面是我项目的tsconfig.json

{
    "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".我的Typescript版本是“typescript”:“^3.9.5”,节点版本是我们 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.我只是想确认我是否将tsconfig.json文件中的target"target": "es6" to “target”:“es2020”`。它将如何影响我当前的项目或者我很好。

TypeScript is a superset of ES6, so you're essentially writing TS code using ES6 version of JavaScript. TypeScript 是 ES6 的超集,因此您实际上是在使用 JavaScript 的 ES6 版本编写 TS 代码。 However, when compiled, the resulting JS code can be in ES5 or earlier.但是,编译后,生成的 JS 代码可以在 ES5 或更早版本中。 You need to define which version of JS the compiler should transpile into.您需要定义编译器应该转译成哪个版本的 JS。 This can be set using target option这可以使用目标选项设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM