TS的tsconfig.json配置


一切教程以官方文檔為准

  初始化一個tsconfig.json配置文件tsc --init

信息配置信息:

{
  "compilerOptions": {
    // "incremental": true,                       // 增置編譯
    // "tsBuildlnfoFile": "./buildFile",          // 增置編譯文件的存儲位置
  // "diagnostics": true,              // 打印診斷倍息
// "target": "es5", // 目標語言的版本 // "module": "commonjs", // 生成代碼的模塊標准 // "outFile": "./app-js", // 將多個相互依賴的文件生成一個文件,可以用在AMD模塊中 // "lib": [], // TS 需要引用的庫,即聲明文件,es5 默認"dom", "es5", "scripthost" // "allowJs": true, // 允許編譯:IS 文件(js、jsx) // "checkJs": true, // 允許在JS文件中報錯,通常與allowJS _起使用 // "outDir": "./dist", // 指定輸出目錄 // "rootDir": "./", // 指定輸入文件目錄(用於輸出) // "declaration": true, // 生成聲明文件 // "declarationDir": "./d", // 聲明文件的路徑 // "emitDeclarationOnly": true, // 只生成聲明文件 // "sourceMap": true, // 生成目標文件的 sourceMap // "inlineSourceMap": true, // 生成目標文件的 inline sourceMap // "declarationMap": true, // 生成聲明文件的 sourceMap // "typeRoots":[], // 聲明文件目錄,默認node_modules/@types // "types":[], // 聲明文件包 // "removeComments":true, // 刪除注釋 // "noEmit": true, // 不輸出文件 // "noEmitOnError": true, // 發生錯誤時不輸出文件 // "noEmitHelpers": true, // 不生成helper 函數,需要額外安裝ts-helpers // "importHelpers": true, // 通過tslib 引入 helper 函數,文件必須是模塊 // unoEmitOnErrorM: true, // 發生錯誤時不輸出文件 // "noEmitHelpers": true, // 不生成 helper 函數,需額外安裝 ts-helpers // "importHelpers": true, // 通過tslib引入helper函數,文件必須是模塊 // "downlevellteration" : true, // 降級遍歷器的實現(es3/5) // "strict": true, // 開啟所有嚴格的類型檢查 // "alwaysStrict": false, // 在代碼中注入"use strict"; // "noImplicitAny": false, // 不允許隱式的any類型 // "strictNullChecksilj false, // 不允許把null、undefined賦值給其他類型變置 // "strictFunctionTypes": false, // 不允許函數參數雙向協變 // "strictPropertyInitialization": false, // 類的實例屬性必須初始化 // strictBindCallApply: false, // 嚴格的 bind/call/apply 檢査 // "noImplicitThis": false, // 不允許this有隱式的any類型 // "noUnusedLocals": true, // 檢査只聲明,未使用的局部變置 // "nollnusedParameters": true, // 檢查未使用的函數參數 // "noFallthroughCasesInSwitch": true, // 防止switch語句貫穿 // "noImplicitReturns": true, // 每個分支都要有返回值 // "esModulelnterop": true, // 允許export = 導出,由import from導入 // "allowUrndGlobalAccess": true, // 允許在模塊中訪問UMD全局變置 // "moduleResolution": "node", // 模塊解析策略 // "baseUrl": "./", // 解析非相對模塊的基地址 // "paths": { // "jquery": ["node-modules/jquery/dist/jquery.slim.min.js"] // } // "rootDirs": ["src", "out"], // 將多個目錄放在一個虛擬目錄下,用於運行時 // "listEmittedFiles": true, // 打印輸出的文件 // "listFiles": true, // 打印編譯的文件(包括引用的聲明文件) }, // "include": [ // 指定一個匹配列表(屬於自動指定該路徑下的所有ts相關文件) // "src/**/*.ts", // "src/**/*.tsx", // "src/**/*.vue", // "tests/**/*.ts", // "tests/**/*.tsx" // ], // "exclude": [ // 指定一個排除列表(include的反向操作) // "node_modules" // ], // "files": [ // 指定哪些文件使用該配置(屬於手動一個個指定文件) // "demo.ts" // ] }


免責聲明!

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



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