tsconfig.json ts配置文件解析


tsconfig.json ts配置文件解析

tsconfig

編譯選項

https://www.tslang.cn/docs/handbook/compiler-options.html

示例配置:

{
  "compilerOptions": {
	  //指定生成哪個模塊系統代碼: "None", "CommonJS", "AMD", "System", "UMD", "ES6"或 "ES2015"。
    "module": "commonjs",
		//生成相應的 .d.ts文件。
    "declaration": true,
		//刪除所有注釋,除了以 /!*開頭的版權信息。
    "removeComments": true,
		//給源碼里的裝飾器聲明加上設計類型元數據。
    "emitDecoratorMetadata": true,
		//啟用實驗性的ES裝飾器。
    "experimentalDecorators": true,
		//指定ECMAScript目標版本 "ES3"(默認), "ES5", "ES6"/ "ES2015", "ES2016", "ES2017"或 "ESNext"。
    "target": "es2017",
		//	允許編譯javascript文件。
    "allowJs": true,
    "checkJs": true,           // 允許在 JS 文件中報錯,通常與 allowJS 一起使用
    "sourceMap": true,           // 生成目標文件的 sourceMap
    "resolveJsonModule": true,
		//生成相應的 .map文件。
    "sourceMap": true,
		//重定向輸出目錄。
    "outDir": "./dist",
		//解析非相對模塊名的基准目錄
    "baseUrl": "./",
    "incremental": true,
    // "strict": true,                        // 開啟所有嚴格的類型檢查
    // "alwaysStrict": false,                 // 在代碼中注入 "use strict";
    // "noImplicitAny": false,                // 不允許隱式的 any 類型
    "strictNullChecks": true,             // 不允許把 null、undefined 賦值給其他類型變量
    // "strictFunctionTypes": false           // 不允許函數參數雙向協變
    // "strictPropertyInitialization": false, // 類的實例屬性必須初始化
    // "strictBindCallApply": false,          // 嚴格的 bind/call/apply 檢查
    "noImplicitThis": false,               // 不允許 this 有隱式的 any 類型
  },
  "exclude": ["node_modules", "dist"]
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM