This error occurs when a TypeScript composite project tries to use compiler options that are incompatible with composite project configuration. The most common cause is conflicting settings between composite mode and skipLibCheck options.
TypeScript composite projects are designed to work as part of a monorepo build system, where project references are resolved in a specific order. When you enable the `composite` option in a `tsconfig.json` file, you're telling TypeScript that: 1. This project is part of a larger multi-project setup 2. It should emit `.tsbuildinfo` files for build caching 3. Other projects can reference this project as a dependency The error "Composite projects may not ask for all files" indicates a conflict between what the composite project configuration requires and certain compiler options that would cause TypeScript to process files in ways incompatible with the composite build system. This typically happens when options like `skipLibCheck` are used incorrectly or when the project structure doesn't properly align with composite project constraints.
First, confirm that composite is explicitly set to true in your tsconfig.json:
{
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true
}
}The declaration, declarationMap, and sourceMap options are required for composite projects.
Ensure your include and exclude arrays are explicit and don't conflict with other projects:
{
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"dist",
"**/*.test.ts"
]
}Avoid using overly broad patterns like ["src"] which might include unintended files. Use exact paths relative to the project root.
If you're using skipLibCheck, verify it's compatible with your composite setup:
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true
}
}If you still get the error, try removing skipLibCheck for the composite project itself:
{
"compilerOptions": {
"composite": true
}
}You can use skipLibCheck in consumer projects that reference this one, but not in the base composite project.
Check that references in your tsconfig.json point to valid paths with proper tsconfig.json files:
{
"compilerOptions": {
"composite": true
},
"references": [
{ "path": "../utils" },
{ "path": "../types" }
]
}Each referenced project must:
- Have its own tsconfig.json with composite: true
- Contain a src directory or proper include pattern
- Not include files from parent or sibling projects
Remove build artifacts and cache, then rebuild using --build:
# Remove all .tsbuildinfo files and dist directories
find . -name "*.tsbuildinfo" -delete
find . -name "dist" -type d -exec rm -rf {} + 2>/dev/null || true
# Rebuild using the composite build system
tsc --build tsconfig.json
# Or rebuild with verbose output to see what's happening
tsc --build tsconfig.json --listFilesEnsure all projects use the same TypeScript version:
npm list typescriptAll projects should use the same major.minor version:
{
"devDependencies": {
"typescript": "^5.3.0"
}
}If versions differ, update them:
npm install -D typescript@latest### Understanding Composite Projects
Composite projects enforce stricter rules than regular TypeScript projects:
1. Separate declaration files: Declaration files (.d.ts) for referenced projects are used instead of scanning source files
2. No circular references: Projects cannot reference each other circularly
3. Explicit boundaries: Each project must have clear include/exclude boundaries
4. Build order matters: tsc --build determines and respects dependency order
### skipLibCheck in Monorepos
The skipLibCheck option was designed for single-project setups to speed up builds. In composite projects:
- In composite project root: May cause conflicts with the build system's file resolution
- In consumer projects: Generally safe to use to speed up builds
- Alternative: Use skipDefaultLibCheck instead for better control
### Debugging File Inclusion
If you're unsure what files are being included, use diagnostic flags:
tsc --build --listFilesOnly
tsc --build --diagnosticsThis shows exactly which files TypeScript is processing and how long it takes.
### Monorepo Structure Best Practice
my-monorepo/
├── tsconfig.json # Root tsconfig (references field)
├── packages/
│ ├── utils/
│ │ ├── tsconfig.json # composite: true, include: ["src"]
│ │ ├── src/
│ │ │ └── index.ts
│ │ └── dist/
│ ├── types/
│ │ ├── tsconfig.json
│ │ ├── src/
│ │ └── dist/
│ └── app/
│ ├── tsconfig.json
│ ├── src/
│ └── dist/Each package's tsconfig should only include its own src directory.
Function expression requires a return type
Function expression requires a return type
Value of type 'string | undefined' is not iterable
How to fix "Value is not iterable" in TypeScript
Type 'undefined' is not assignable to type 'string'
How to fix "Type undefined is not assignable to type string" in TypeScript
Type narrowing from typeof check produces 'never'
How to fix "Type narrowing produces never" in TypeScript
Type parameter 'T' has conflicting constraints
How to fix "Type parameter has conflicting constraints" in TypeScript