Skip to main content

no-esnext-target-in-library

Disallow "target": "ESNext" in tsconfig*.json files.

Targeted pattern scopeโ€‹

The compilerOptions.target field in any tsconfig*.json file.

What this rule reportsโ€‹

This rule reports whenever compilerOptions.target is set to "ESNext".

Why this rule existsโ€‹

"ESNext" does not refer to a fixed ECMAScript version โ€” it always means "the latest features available in the current version of TypeScript". When a project is built with "target": "ESNext", the emitted JavaScript syntax may change with every TypeScript upgrade even if the source code does not.

Pinning to a concrete target version like "ES2022" makes the output stable across TypeScript upgrades and gives consumers and runtimes a clearer baseline.

โŒ Incorrectโ€‹

{
"compilerOptions": {
"target": "ESNext"
}
}

The emitted output target can shift after a routine TypeScript upgrade.

โœ… Correctโ€‹

{
"compilerOptions": {
"target": "ES2022"
}
}

When not to use itโ€‹

Disable this rule for experimental or tightly controlled environments that intentionally track the latest runtime features and accept the instability of ESNext.

Package documentationโ€‹

Rule catalog ID: R008

Further readingโ€‹