選項(xiàng) | 類型 | 默認(rèn)值 | 描述 |
---|---|---|---|
--allowJs |
boolean |
true |
允許編譯javascript文件。 |
--allowSyntheticDefaultImports |
boolean |
(module === "system") |
允許從沒有設(shè)置默認(rèn)導(dǎo)出的模塊中默認(rèn)導(dǎo)入。這并不影響代碼的顯示,僅為了類型檢查。 |
--allowUnreachableCode |
boolean |
false |
不報(bào)告執(zhí)行不到的代碼錯(cuò)誤。 |
--allowUnusedLabels |
boolean |
false |
不報(bào)告未使用的標(biāo)簽錯(cuò)誤。 |
--charset |
string |
"utf8" |
輸入文件的字符集。 |
--declaration -d |
boolean |
false |
生成相應(yīng)的'.d.ts'文件。 |
--diagnostics |
boolean |
false |
顯示診斷信息。 |
--emitBOM |
boolean |
false |
在輸出文件的開頭加入BOM頭(UTF-8 Byte Order Mark)。 |
--emitDecoratorMetadata [1] |
boolean |
false |
給源碼里的裝飾器聲明加上設(shè)計(jì)類型元數(shù)據(jù)。查看issue #2577了解更多信息。 |
--experimentalDecorators [1] |
boolean |
false |
實(shí)驗(yàn)性啟用ES7裝飾器支持。 |
--forceConsistentCasingInFileNames |
boolean |
false |
不允許不一致包裝引用相同的文件。 |
--help -h |
打印幫助信息。 | ||
--init |
初始化TypeScript項(xiàng)目并創(chuàng)建一個(gè)tsconfig.json 文件。 |
||
--inlineSourceMap |
boolean |
false |
生成單個(gè)sourcemaps文件,而不是將每sourcemaps生成不同的文件。 |
--inlineSources |
boolean |
false |
將代碼與sourcemaps生成到一個(gè)文件中,要求同時(shí)設(shè)置了--inlineSourceMap 或--sourceMap 屬性。 |
--isolatedModules |
boolean |
false |
無條件地給沒有解析的文件生成imports。 |
--jsx |
string |
"Preserve" |
在'.tsx'文件里支持JSX:'React' 或 'Preserve'。查看JSX。 |
--listFiles |
boolean |
false |
編譯過程中打印文件名。 |
--locale |
string |
(platform specific) | 顯示錯(cuò)誤信息時(shí)使用的語言,比如:en-us。 |
--mapRoot |
string |
null |
為調(diào)試器指定指定sourcemap文件的路徑,而不是使用生成時(shí)的路徑。當(dāng).map 文件是在運(yùn)行時(shí)指定的,并不同于js 文件的地址時(shí)使用這個(gè)標(biāo)記。指定的路徑會(huì)嵌入到sourceMap 里告訴調(diào)試器到哪里去找它們。 |
--module -m |
string |
(target === "ES6" ? "ES6" : "commonjs") |
指定生成哪個(gè)模塊系統(tǒng)代碼:'commonjs','amd','system',或 'umd'或'es2015'。只有'amd'和'system'能和--outFile 一起使用。當(dāng)目標(biāo)是ES5或以下的時(shí)候不能使用'es2015'。 |
--moduleResolution |
string |
(module === 'amd' | 'system' | 'ES6' ? 'classic' : 'node') |
決定如何處理模塊?;蛘呤?node'對(duì)于Node.js/io.js,或者是'classic'(默認(rèn))。查看[模塊解析](./Module Resolution.md)了解詳情。 |
--newLine |
string |
(platform specific) | 當(dāng)生成文件時(shí)指定行結(jié)束符:'CRLF'(dos)或 'LF' (unix)。 |
--noEmit |
boolean |
false |
不生成輸出文件。 |
--noEmitHelpers |
boolean |
false |
不在輸出文件中生成用戶自定義的幫助函數(shù)代碼,如__extends 。 |
--noEmitOnError |
boolean |
false |
報(bào)錯(cuò)時(shí)不生成輸出文件。 |
--noFallthroughCasesInSwitch |
boolean |
false |
報(bào)告switch語句的fallthrough錯(cuò)誤。(即,不允許switch的case語句貫穿) |
--noImplicitAny |
boolean |
false |
在表達(dá)式和聲明上有隱含的'any'類型時(shí)報(bào)錯(cuò)。 |
--noImplicitReturns |
boolean |
false |
不是函數(shù)的所有返回路徑都有返回值時(shí)報(bào)錯(cuò)。 |
--noImplicitUseStrict |
boolean |
false |
模塊輸出中不包含'use strict'指令。 |
--noLib |
boolean |
false |
不包含默認(rèn)的庫文件(lib.d.ts)。 |
--noResolve |
boolean |
false |
不把/// <reference``> 或模塊導(dǎo)入的文件加到編譯文件列表。 |
--out |
string |
null |
棄用。使用 --outFile 代替。 |
--outDir |
string |
null |
重定向輸出目錄。 |
--outFile |
string |
null |
將輸出文件合并為一個(gè)文件。合并的順序是根據(jù)傳入編譯器的文件順序和///<reference``> 和import 的文件順序決定的。查看輸出文件順序文件了解詳情。 |
--preserveConstEnums |
boolean |
false |
保留const 和enum 聲明。查看const enums documentation了解詳情。 |
--pretty [1] |
boolean |
false |
給錯(cuò)誤和消息設(shè)置樣式,使用顏色和上下文。 |
--project -p |
string |
null |
編譯指定目錄下的項(xiàng)目。這個(gè)目錄應(yīng)該包含一個(gè)tsconfig.json 文件來管理編譯。查看tsconfig.json文檔了解更多信息。 |
--reactNamespace |
string |
"React" |
當(dāng)目標(biāo)為生成'react' JSX時(shí),指定createElement 和__spread 的調(diào)用對(duì)象 |
--removeComments |
boolean |
false |
刪除所有注釋,除了以/!* 開頭的版權(quán)信息。 |
--rootDir |
string |
(common root directory is computed from the list of input files) | 僅用來控制輸出的目錄結(jié)構(gòu)--outDir 。 |
--skipDefaultLibCheck |
boolean |
false |
|
--sourceMap |
boolean |
false |
生成相應(yīng)的'.map'文件。 |
--sourceRoot |
string |
null |
指定TypeScript源文件的路徑,以便調(diào)試器定位。當(dāng)TypeScript文件的位置是在運(yùn)行時(shí)指定時(shí)使用此標(biāo)記。路徑信息會(huì)被加到sourceMap 里。 |
--strictNullChecks |
boolean |
false |
在嚴(yán)格的null 檢查模式下,null 和undefined 值不包含在任何類型里,只允許用它們自己和any 來賦值(有個(gè)例外,undefined 可以賦值到void )。 |
--stripInternal [1] |
boolean |
false |
不對(duì)具有/** @internal */ JSDoc注解的代碼生成代碼。 |
--suppressExcessPropertyErrors [1] |
boolean |
false |
阻止對(duì)對(duì)象字面量的額外屬性檢查。 |
--suppressImplicitAnyIndexErrors |
boolean |
false |
阻止--noImplicitAny 對(duì)缺少索引簽名的索引對(duì)象報(bào)錯(cuò)。查看issue #1232了解詳情。 |
--target -t |
string |
"ES5" |
指定ECMAScript目標(biāo)版本'ES3' (默認(rèn)),'ES5',或'ES6'[1] |
--traceResolution |
boolean |
false |
生成模塊解析日志信息 |
--version -v |
打印編譯器版本號(hào)。 | ||
--watch -w |
在監(jiān)視模式下運(yùn)行編譯器。會(huì)監(jiān)視輸出文件,在它們改變時(shí)重新編譯。 |
[1] 這些選項(xiàng)是試驗(yàn)性的。