typescript - 在 monorepo 專案中排除指令無法正常運作
我有一個具有以下架構的單一倉庫專案:
my-monorepo
├── packages
│ ├── package1
│ │ └── ./tsconfig.json(extend the root configuration)
│ ├── package2
│ │ └── ./tsconfig.json(extend the root configuration)
├── tsconfig.json(Root base ts configuration)
這個問題在於,我在根基配置中有選項 exclude,但它不起作用。我已經嘗試在每個包的本地 tsconfig.json 文件中設置 exclude 選項,但這也沒有作用。
根目錄 ts 配置
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"declaration": true,
"declarationDir": "dist",
"esModuleInterop": true,
"jsx": "react",
"lib": ["es6", "dom", "es2016", "es2017", "ES2019"],
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"rootDir": "src",
"skipLibCheck": true,
"sourceMap": true,
"target": "es5"
},
"include": ["**/*.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "dist", "**/*.config.ts", "**/*.setup.ts"]
}
套件 1/2 ts 配置
{
"extends": "../../../../../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./src",
"declarationDir": "dist",
"skipLibCheck": true,
"rootDir": "src"
},
"include": ["**/*.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "dist", "**/*.config.ts", "**/*.setup.ts"]
}
我想要排除根目錄和每個套件中的 jest.config.ts 文件,但這個文件仍然有 ts 錯誤,根據 glob "**/*.config.ts" 這個文件應該被排除,那我認為編譯器沒有採用這個配置。