2017-02-23 204 views
10

我对Typescript颇为陌生。 tsconfig.json中的Target是什么意思?Typescript - tsconfig中的目标是什么?

{ 
    "compilerOptions": 
    { 
    "sourceMap": true, 
    "target": "es5", 
    "module": "commonjs", 
    "jsx": "react", 
    "moduleResolution": "classic", 
    "lib": [ "es2015", "dom", "es2017" ] 
    } 
} 
+0

请下次再尝试使用搜索引擎。 https://www.typescriptlang.org/docs/handbook/compiler-options.html –

+1

@SebastianSebald我做了搜索,并得到该网页,但不明白, 这是否意味着在编写它时检查代码是在es5格式和在transpiling es5是目标? –

+0

您在* TypeScript *中编写代码,目标定义编译目标。 –

回答

17

我对于Typescript很新颖。 tsconfig.json中的Target是什么意思?

target表示其中的JavaScript的目标应该从给定的打字稿发射。例子:

target:es5

()=>null将成为function(){return null}为ES5没有箭头的功能。

target:es6

()=>null将变得()=>null作为ES6具有箭头的功能。

+0

我仍然需要巴贝尔,如果我的目标是es5 也我的脚本代码包含异步和等待,将编译,如果我给目标为es5? –

+0

不需要为此而生气 – basarat