使用 typescript 的時候會有不少設定值可以設定,
typescript compiler (tsc) 有可以產生預設值
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tsc -init |
產生出來的 tsconfig.json 內容有一些預設值跟已經被註解的範本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
/* Basic Options */ | |
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | |
// "lib": [], /* Specify library files to be included in the compilation. */ | |
/* Strict Type-Checking Options */ | |
"strict": true, /* Enable all strict type-checking options. */ | |
/* Module Resolution Options */ | |
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ | |
/* Advanced Options */ | |
"skipLibCheck": true, /* Skip type checking of declaration files. */ | |
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ | |
} | |
} |
target:編譯產生的 ECMAScript 版本
module:編譯產生出的模組引用方式
strict:型別檢查
lib:預設載入 js 函式庫
dom:瀏覽器 DOM 物件存取相關的 API - window
, document
, etc.
es2015:包含 ES2015 相關的 API - array.find
, Promise
, Proxy
, Symbol
, Map
, Set
, Reflect
, etc.
es2016:包含 ES2016 相關的 API - array.include
, etc.
outDir:輸出編譯結果的資料夾
可以參考 官網
沒有留言:
張貼留言