How to fix Triple-slash directive 'types' requires 'skipLibCheck' in TypeScript
TypeScript refuses to compile when a triple-slash `types` directive appears inside a file but the compiler is still checking library declaration files. The directive is only permitted when `skipLibCheck` is turned on, so the fix is either to drop the directive or to let the compiler skip library checking
Quick fix
Fixes Triple-slash directive 'types' requires 'skipLibCheck'
{
"compilerOptions": {
"types": ["node", "jest"]
}
}- Drop the triple-slash types directive and declare the dependency in tsconfig
- Enable skipLibCheck when the directive comes from a dependency
- Keep strong guarantees in production builds
{"compilerOptions": {"types": ["node", "jest"]}}Triple-slash directive 'types' requires 'skipLibCheck'
What this error means
A `/// <reference types="..." />` directive declares that the current file depends on another declaration package (usually an `@types` package). These directives were invented for legacy scripts, not modern modules, so the compiler only honors them when it skips type checking for library files. Turning on `skipLibCheck` tells TypeScript to trust the ambient declarations it already loaded from `node_modules`, which is the same context that the triple-slash directive expects. Without `skipLibCheck`, the compiler would try to re-verify every referenced declaration and the directive creates conflicting ordering assumptions, so it halts with "Triple-slash directive 'types' requires 'skipLibCheck'".
Typical symptoms
- `tsc` exits with the shown message before producing output
- The complaint points at a `/// <reference types="..." />` line that lives near the top of a `.d.ts` or `.ts` file
- Removing unrelated imports/exports does not help because the directive itself is invalid unless `skipLibCheck` is true
- The error surfaces when a declaration file shipped from `node_modules` tries to pull in another ambient package
- Build pipelines or `tsc --build` stops even if the referenced package normally compiles, because the compiler refuses to include it without `skipLibCheck`
Common causes
- A declaration file still includes `/// <reference types="...">` even though the project checks all library files
- Third-party `@types` packages use this directive to bring in peer ambient types, but the consuming project keeps `skipLibCheck` off
- A generator emits a triple-slash types reference in your own `.d.ts` stub, so the compiler runs into the restriction while type checking the emitted file
- You rely on legacy `/// <reference types.../>` directives instead of using `tsconfig.json`'s `types` or `typeRoots` options
- An ambient declaration references another `@types` package, and tsc enforces `skipLibCheck` before honoring that cross-reference
How to fix "Triple-slash directive 'types' requires 'skipLibCheck'"
Triple-slash types directives work like declarative imports for ambient packages. Instead of editing the file, list the package under "compilerOptions.types" (or adjust "typeRoots") in tsconfig. Example:
{
"compilerOptions": {
"types": ["node", "jest"]
}
}Now the compiler loads those ambient modules automatically and the error disappears, because the file no longer contains a /// <reference types="..." /> comment that demands skipLibCheck.
If a third-party declaration file or a generated .d.ts still uses /// <reference types=... />, the only supported path is to allow TypeScript to skip library checking. Add or flip this option in tsconfig:
{
"compilerOptions": {
"skipLibCheck": true
}
}skipLibCheck tells the compiler to skip verifying every .d.ts file inside node_modules, which is exactly what TypeScript expects before honoring the extra triple-slash reference. Run npx tsc --project tsconfig.json afterwards to confirm the diagnostic disappears.
Because skipLibCheck weakens guarantees, some teams only enable it during declaration generation or when bundling. Create a secondary config for that phase:
// tsconfig.build.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"skipLibCheck": true,
"declaration": true,
"outDir": "./dist"
}
}Use tsc --project tsconfig.build.json for publishing, while day-to-day development still runs tsc --project tsconfig.json with skipLibCheck disabled. This way, triple-slash types from dependencies stay compatible without letting the main build miss real library errors.
Frequently asked questions
- What does "Triple-slash directive 'types' requires 'skipLibCheck'" mean?
- " /> directive declares that the current file depends on another declaration package (usually an @types package). These directives were invented for legacy scripts, not modern modules, so the compiler only honors them when it skips type checking for library files. Turning on skipLibCheck tells TypeScript to trust the ambient declarations it already loaded from node_modules, which is the same context that the triple-slash directive expects.
- How do I fix "Triple-slash directive 'types' requires 'skipLibCheck'"?
- TypeScript refuses to compile when a triple-slash types directive appears inside a file but the compiler is still checking library declaration files. The directive is only permitted when skipLibCheck is turned on, so the fix is either to drop the directive or to let the compiler skip library checking
- What causes "Triple-slash directive 'types' requires 'skipLibCheck'"?
- A declaration file still includes /// <reference types="..."> even though the project checks all library files Third-party @types packages use this directive to bring in peer ambient types, but the consuming project keeps skipLibCheck off A generator emits a triple-slash types reference in your own .d.ts stub, so the compiler runs into the restriction while type checking the emitted file
- Is the "Triple-slash directive 'types' requires 'skipLibCheck'" 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 Handbook - Triple-Slash Directives(Official Docs)
- ๐TypeScript TSConfig Reference - skipLibCheck(Official Docs)