2017-09-07 61 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 文件将被忽略。