2017-02-23 176 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

相關問題