TypeScript 里 tsconfig.json 文件的作用
What is a tsconfig.json
目錄中存在 tsconfig.json 文件表明該目錄是 TypeScript 項(xiàng)目的根目錄。 tsconfig.json 文件指定了編譯項(xiàng)目所需的根文件和編譯器選項(xiàng)。
JavaScript 項(xiàng)目可以改用 jsconfig.json 文件,它的作用幾乎相同,但默認(rèn)情況下啟用了一些與 JavaScript 相關(guān)的編譯器標(biāo)志。
根據(jù)您打算在其中運(yùn)行代碼的 JavaScript 運(yùn)行時(shí)環(huán)境,您可以在 github.com/tsconfig/bases 上使用基本配置。 這些是您的項(xiàng)目從中擴(kuò)展的 tsconfig.json 文件,通過處理運(yùn)行時(shí)支持來簡(jiǎn)化您的 tsconfig.json。
例如,如果您正在編寫一個(gè)使用 Node.js 版本 12 及更高版本的項(xiàng)目,那么您可以使用 npm 模塊 @tsconfig/node12:
{"extends": "@tsconfig/node12/tsconfig.json","compilerOptions": {"preserveConstEnums": true},"include": ["src/**/*"],"exclude": ["node_modules", "**/*.spec.ts"] }詳細(xì)參數(shù)說明參考這個(gè)鏈接
Specifies an array of filenames or patterns to include in the program. These filenames are resolved relative to the directory containing the tsconfig.json file.
一個(gè)例子:
{"include": ["src/**/*", "tests/**/*"] }結(jié)果:scripts 文件夾里的 ts 文件沒有被包含進(jìn)去。
更多Jerry的原創(chuàng)文章,盡在:“汪子熙”:
總結(jié)
以上是生活随笔為你收集整理的TypeScript 里 tsconfig.json 文件的作用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: GTA5超跑排名2018 GTA5超级跑
- 下一篇: JS生成简单随机答案选择器,小抽奖器