2017-09-07 62 views
1

在打字稿中,如何告訴編譯器實際輸出類,常量,允許等,而​​不是將所有內容都轉換爲變量和函數?我正在使用Typescript 2.4.1。TypeScript輸出ES5代碼

這裏是我的tsconfig:

{ 
    "compilerOptions": { 
    /* Basic Options */ 
    "target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ 
    "module": "es2015", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 
    "moduleResolution": "node", 
    "strict": false, /* Enable all strict type-checking options. */ 
    "lib": [ 
     "es2015", 
     "dom", 
     "es2016", 
     "es2017" 
    ], 
    "alwaysStrict": true 
    } 
} 
+2

你的編譯器選項看起來不錯,你確定那是使用的配置嗎? –

+0

瞧!原來'tsc MyFile.ts'顯然不使用當前目錄中的tsconfig.json文件。如果你喜歡的話,把它放在一個答案中。 –

回答

3

你必須調用tsc沒有任何輸入文件作爲參數,它使用tsconfig.json

From the documentation

當輸入文件的命令行上指定,tsconfig.json 文件將被忽略。