Skip to content

feat(parser): add onUnsupportedTypeScriptVersion option to error on unsupported TypeScript versions - #12465

Merged
JoshuaKGoldberg merged 18 commits into
typescript-eslint:mainfrom
zaewc:feat/on-unsupported-typescript-version
Jul 18, 2026
Merged

JoshuaKGoldberg merged 18 commits into
typescript-eslint:mainfrom
zaewc:feat/on-unsupported-typescript-version

Conversation

@zaewc

@zaewc zaewc commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

Adds a new onUnsupportedTypeScriptVersion parser option that controls how the parser reacts when run with a TypeScript version that isn't officially supported. It accepts:

  • 'warn' (default) - log the warning to the console (existing behavior)
  • 'error' - log the message and throw, so the lint run fails. This is the use case from the issue: catching unsupported TypeScript versions in CI (e.g. a Dependabot/Renovate bump) where warnings go unnoticed and only non-zero exit codes are detected
  • 'ignore' - ignore

The default stays 'warn', so this is a non-breaking, opt-in change

notes

  • @typescript-eslint/types: added onUnsupportedTypeScriptVersion to ParserOptions and marked warnOnUnsupportedTypeScriptVersion as @deprecated
  • @typescript-eslint/typescript-estree: added the option to TSESTreeOptions, and reworked warnAboutTSVersion -> handleUnsupportedTSVersion to branch on warn/error/ignore. 'error' throws regardless of TTY/loggerFn, since the CI scenario this targets is non-TTY
  • @typescript-eslint/parser: maps the option through, falling back to the deprecated warnOnUnsupportedTypeScriptVersion boolean when the new option isn't set (true -> 'warn', false -> 'ignore'). onUnsupportedTypeScriptVersion takes precedence when both are provided

warnOnUnsupportedTypeScriptVersion continues to work, it's deprecated but still respected == No default behavior changes

docs & tests

  • Documented the new option (and deprecated the old one) in Parser.mdx and Dependency_Versions.mdx
  • Added tests covering warn/error/ignore behavior and the precedence of the new option over the deprecated boolean

@typescript-eslint

Copy link
Copy Markdown
Contributor

Thanks for the PR, @zaewc!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@netlify

netlify Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for typescript-eslint failed.

Name Link
🔨 Latest commit 84777db
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/6a55fac924d08e0008c6eaec

@nx-cloud

nx-cloud Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit bf0bab9

Command Status Duration Result
nx run-many --target=build --parallel --exclude... ❌ Failed 14s View ↗

💡 Dealing with memory or CPU issues? See memory and CPU details with the resource usage add-on ↗.


☁️ Nx Cloud last updated this comment at 2026-07-14 09:02:05 UTC

@zaewc zaewc changed the title Feat/on unsupported typescript version feat(parser): add onUnsupportedTypeScriptVersion option to error on unsupported TypeScript versions Jun 30, 2026
@zaewc

zaewc commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor Author

The Build All Packages job failed, but I believe it's a stale Nx Cloud cache rather than a real type error, and could use a maintainer re-run. 🙏

In the failing run, the task table shows types:build as a Remote Cache Hit while typescript-estree:build rebuilt fresh. The cached types artifact predates the new onUnsupportedTypeScriptVersion field, so in packages/parser/src/parser.ts the access parserOptions.onUnsupportedTypeScriptVersion falls through to the [additionalProperties: string]: unknown index signature on ParserOptions. That makes unknown ?? 'warn' resolve to {} | 'warn' | 'ignore', which produces:

src/parser.ts:130:5 - error TS2322: Type '{}' is not assignable to type '"error" | "ignore" | "warn" | undefined'.

The other two reported errors cascade from the same stale types output.

Locally, after clearing all dist/.tsbuildinfo and running a no-cache build of the affected packages, everything compiles cleanly:

nx run-many -t build -p types typescript-estree scope-manager utils parser --skip-nx-cache
→ NX  Successfully ran target build for 5 projects

So a fresh types:build (with the new field) resolves it. Could a maintainer re-run the CI workflow? If a stale-cache re-run isn't enough, I'm happy to push a small change to types to force a cache miss. Thanks!

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good start, I like the direction & docs! Requesting changes on the throwing behavior. Thanks! ✨

Comment thread docs/packages/Parser.mdx Outdated
:::caution Deprecated
Use [`onUnsupportedTypeScriptVersion`](#onunsupportedtypescriptversion) instead.
`true` is equivalent to `'warn'` and `false` is equivalent to `'ignore'`.
If both options are provided, `onUnsupportedTypeScriptVersion` takes precedence.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Feature] Let's throw an error if both are provided. That's an invalid config and we don't want to have to support that. We've had issues in the past where folks expected technically-invalid configs to run and were surprised when they didn't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 0c44b7c

parseForESLint now throws when both onUnsupportedTypeScriptVersion and the deprecated warnOnUnsupportedTypeScriptVersion are set, instead of silently picking one. Updated the docs and tests to match.

Thanks 💖

Comment thread docs/packages/Parser.mdx

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Praise] Great docs 🙂

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Jul 1, 2026
@JoshuaKGoldberg

JoshuaKGoldberg commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Re the builds: odd. I merged the latest master in and rebuilt. It builds locally for me just fine. This might be an issue with our Nx setup. Cc @JamesHenry

@codecov

codecov Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.91%. Comparing base (c4d9c73) to head (c3f4306).
⚠️ Report is 7 commits behind head on main.

⚠️ Current head c3f4306 differs from pull request most recent head 84777db

Please upload reports for the commit 84777db to get more accurate results.

Files with missing lines Patch % Lines
...ipt-estree/src/parseSettings/warnAboutTSVersion.ts 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12465      +/-   ##
==========================================
- Coverage   87.06%   86.91%   -0.15%     
==========================================
  Files         515      511       -4     
  Lines       16643    16450     -193     
  Branches     5204     5203       -1     
==========================================
- Hits        14490    14298     -192     
+ Misses       1462     1460       -2     
- Partials      691      692       +1     
Flag Coverage Δ
unittest 86.91% <90.00%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...pt-estree/src/parseSettings/createParseSettings.ts 85.52% <100.00%> (+0.19%) ⬆️
...ipt-estree/src/parseSettings/warnAboutTSVersion.ts 83.33% <87.50%> (-9.53%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zaewc

zaewc commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

@JoshuaKGoldberg @StyleShit

Only types overrides its build inputs to src/generated/**, so other src changes didn't bust the cache -> CI kept building the parser against a stale types

Removing that override fixed it. happy to revert if it was there for a reason

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! ✨

Just a couple of small touchups that we can always apply before merge. Happy to do them tomorrow before the weekly release.

Comment thread docs/packages/Parser.mdx Outdated
"copy-ast-spec"
],
"inputs": [
"{projectRoot}/src/generated/**/*"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be correct, but let's just switch it out to a separate change. We as maintainers can verify this PR works on our local builds. Fiddling with the Nx setup can be very finnicky.

Suggested change
"{projectRoot}/src/generated/**/*"
],
"inputs": [
"{projectRoot}/src/generated/**/*"

Back-linking to where this was also added in an unrelated PR (which reinforces my hesitation): https://github.com/typescript-eslint/typescript-eslint/pull/11355/changes#r2347376398

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

73b7c43 I reverted!

Comment thread packages/typescript-estree/tests/lib/warn-on-unsupported-ts.test.ts Outdated
Comment thread packages/typescript-estree/tests/lib/warn-on-unsupported-ts.test.ts Outdated
…st.ts

Co-authored-by: Josh Goldberg ✨ <github@joshuakgoldberg.com>
zaewc and others added 3 commits July 13, 2026 17:13
…st.ts

Co-authored-by: Josh Goldberg ✨ <github@joshuakgoldberg.com>
Co-authored-by: Josh Goldberg ✨ <github@joshuakgoldberg.com>
This reverts commit c3f4306. Keeping the Nx setup change out of this PR
per review; the parser change is verified on local builds.
@zaewc
zaewc requested a review from JoshuaKGoldberg July 13, 2026 08:16
@github-actions github-actions Bot removed the awaiting response Issues waiting for a reply from the OP or another party label Jul 13, 2026

@StyleShit StyleShit left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some non-blocking documentation and typing stuff

Comment thread docs/packages/Parser.mdx Outdated
Comment thread docs/users/Dependency_Versions.mdx Outdated
Comment thread packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts Outdated
zaewc and others added 3 commits July 14, 2026 17:57
Co-authored-by: Evyatar Daud <32631382+StyleShit@users.noreply.github.com>
Co-authored-by: Evyatar Daud <32631382+StyleShit@users.noreply.github.com>
@zaewc
zaewc requested a review from StyleShit July 14, 2026 09:01
@StyleShit StyleShit added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Jul 14, 2026

@JoshuaKGoldberg JoshuaKGoldberg left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build failures still don't happen locally for me. 🚢

Thanks for all the iteration & work on this @zaewc!

@JoshuaKGoldberg
JoshuaKGoldberg merged commit d8f1044 into typescript-eslint:main Jul 18, 2026
20 of 26 checks passed
Comment thread docs/packages/Parser.mdx
projectFolderIgnoreList?: string[];
projectService?: boolean | ProjectServiceOptions;
tsconfigRootDir?: string;
warnOnUnsupportedTypeScriptVersion?: boolean;

@SchroederSteffen SchroederSteffen Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this new option, I'm about to enable it in my projects.
But I noticed that it's missing in this overview at the top.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hugop95 pushed a commit to hugop95/typescript-eslint that referenced this pull request Aug 14, 2026
…nsupported TypeScript versions (typescript-eslint#12465)

* feat(types): add onUnsupportedTypeScriptVersion parser option

* feat(typescript-estree): support onUnsupportedTypeScriptVersion behavior

* feat(parser): map onUnsupportedTypeScriptVersion and deprecated boolean

* test: cover onUnsupportedTypeScriptVersion warn/error/ignore behavior

* docs: document onUnsupportedTypeScriptVersion option

* fix(parser): suppress no-deprecated for backwards-compat option read

* fix(parser): throw error when both onUnsupportedTypeScriptVersion and deprecated warnOnUnsupportedTypeScriptVersion are provided

* chore: remove unused inputs

* Update packages/typescript-estree/tests/lib/warn-on-unsupported-ts.test.ts

Co-authored-by: Josh Goldberg ✨ <github@joshuakgoldberg.com>

* Update packages/typescript-estree/tests/lib/warn-on-unsupported-ts.test.ts

Co-authored-by: Josh Goldberg ✨ <github@joshuakgoldberg.com>

* Update docs/packages/Parser.mdx

Co-authored-by: Josh Goldberg ✨ <github@joshuakgoldberg.com>

* Revert "chore: remove unused inputs"

This reverts commit c3f4306. Keeping the Nx setup change out of this PR
per review; the parser change is verified on local builds.

* Update docs/packages/Parser.mdx

Co-authored-by: Evyatar Daud <32631382+StyleShit@users.noreply.github.com>

* Update docs/users/Dependency_Versions.mdx

Co-authored-by: Evyatar Daud <32631382+StyleShit@users.noreply.github.com>

* fix: standardize severity argument in buildUnsupportedTSVersionMessage function

---------

Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
Co-authored-by: Evyatar Daud <32631382+StyleShit@users.noreply.github.com>
Co-authored-by: Josh Goldberg ✨ <github@joshuakgoldberg.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: configuration option to error on unsupported TypeScript version (onUnsupportedTypeScriptVersion=error)

4 participants