require-declaration-map
Require "declarationMap": true in compilerOptions when "declaration": true
is explicitly present.
Targeted pattern scopeโ
The compilerOptions.declaration and compilerOptions.declarationMap fields in
any tsconfig*.json file.
What this rule reportsโ
This rule reports when compilerOptions is present, compilerOptions.declaration is explicitly true, but compilerOptions.declarationMap is absent or set to false. The rule does not report if compilerOptions is not defined at all.
Why this rule existsโ
When a TypeScript library emits declaration files, editors and other tools use
those .d.ts files for type information. Without a declaration map, "go to
definition" jumps to generated .d.ts output instead of the original TypeScript
source.
With declarationMap: true, TypeScript emits a .d.ts.map file alongside each
.d.ts file so tools can navigate back to the original source.
The auto-fixer adds "declarationMap": true to compilerOptions.
โ Incorrectโ
{
"compilerOptions": {
"declaration": true,
"outDir": "./dist"
}
}
{
"compilerOptions": {
"declaration": true,
"declarationMap": false,
"outDir": "./dist"
}
}
โ Correctโ
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"outDir": "./dist"
}
}
Behavior and migration notesโ
declarationMap: trueonly takes effect whendeclaration: trueis also set. Whendeclarationis absent orfalse, this rule does not report.- The generated
.d.ts.mapfiles must be published alongside.d.tsfiles for consuming projects to benefit. Add the*.d.ts.mapglob to thefilesorexportsentries inpackage.json. - This rule currently checks only the explicit
declaration: truesetting in the same config.
When not to use itโ
Disable this rule for configs that intentionally omit declaration maps โ for example, internal monorepo packages where source is always available locally, or build configs that skip declaration output entirely.
Package documentationโ
Rule catalog ID: R037