How to fix Composite projects may not ask for all files in TypeScript
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.
Quick fix
Fixes TS6059
{
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true
}
}- Verify composite configuration
- Check include and exclude patterns
- Remove or fix skipLibCheck in composite projects
- Verify project references are correct
{"compilerOptions": {"composite": true,"declaration": true,"declarationMap": true,"sourceMap": true}}Composite projects may not ask for all files
What this error means
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.
Typical symptoms
- Error appears when building a TypeScript monorepo with project references
- Error occurs after enabling composite: true in tsconfig.json
- Build fails during tsc --build operations
- The error message specifically mentions composite projects and file selection
- Child projects can build independently but fail when referenced by parent projects
- Error appears inconsistently across different developers or CI environments
Common causes
- skipLibCheck option is incompatible with composite project configuration in some TypeScript versions
- Project structure doesn't properly define which files belong to the composite project
- Include/exclude patterns in tsconfig.json conflict with project references
- Using glob patterns or wildcards in rootDirs with composite mode enabled
- Mismatched TypeScript versions across referenced projects
- Circular project references creating ambiguity about file ownership
- Files are included via multiple project references without clear separation
How to fix "Composite projects may not ask for all files"
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@latestAdvanced notes
### 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.
Frequently asked questions
- What does "TS6059" mean?
- TypeScript composite projects are designed to work as part of a monorepo build system, where project references are resolved in a specific order. json file, you're telling TypeScript that: 1. This project is part of a larger multi-project setup 2.
- How do I fix "TS6059"?
- 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.
- What causes "TS6059"?
- skipLibCheck option is incompatible with composite project configuration in some TypeScript versions Project structure doesn't properly define which files belong to the composite project Include/exclude patterns in tsconfig.json conflict with project references
- Is the "TS6059" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚TypeScript Official Documentation
- 📖TypeScript Project References - Official Docs(Official Docs)
- 📖TypeScript TSConfig: composite option(Official Docs)
- 📖TypeScript TSConfig: skipLibCheck option(Official Docs)
- 🐙
- 🐙
- 🐙