Skip to content

fix(typescript): apply plugin defaults after parsing tsconfig files, honoring extension#2004

Open
newswim wants to merge 2 commits into
rollup:masterfrom
newswim:fix/ts-plugin-defaults-respect-extends
Open

fix(typescript): apply plugin defaults after parsing tsconfig files, honoring extension#2004
newswim wants to merge 2 commits into
rollup:masterfrom
newswim:fix/ts-plugin-defaults-respect-extends

Conversation

@newswim

@newswim newswim commented May 29, 2026

Copy link
Copy Markdown

Rollup Plugin Name: typescript

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes
  • no

Breaking Changes?

  • yes
  • no

List any relevant issue numbers:

resolves #1726
resolves #1583

Description

The util function parseTypescriptConfig spreads DEFAULT_COMPILER_OPTIONS into compilerOptions, which is passed to ts.parseJsonConfigFileContent. So the plugin defaults win over anything inherited via extends, which in turn triggers TS5110 when using typescript@5.x.

The current state requires that users restate module/moduleResolution: nodenext in the rollup config in order to not be forced into default values ({ module: 'esnext', skipLibCheck: true }). This is tenable for small projects, but cumbersome in large monorepos.

The fix

Apply defaults after parseJsonConfigFileContent returns, only for keys the resolved config left unset. ts.convertCompilerOptionsFromJson handles the JSON→enum coercion.

Tests

  • Added a new extends-nodenext fixture
  • Added one unit test on parseTypescriptConfig (version-independent, red on master) and one end-to-end TS5110 check.
  • Two existing tests that fell back to the repo's dev tsconfig now pass module: 'esnext' explicitly; fakeTypescript helper gets a convertCompilerOptionsFromJson stub.

With the patch, tests pass on TS 4.8.4 (bundled) and TS 5.9.3

@shellscape

Copy link
Copy Markdown
Collaborator

@newswim thanks for the PR, but there's a ton of clanker fluff in your PR description. please distill that down. I'd also be interested in seeing the prompt(s) you used to generate this PR.

Comment thread packages/typescript/CHANGELOG.md Outdated
@@ -1,5 +1,13 @@
# @rollup/plugin-typescript ChangeLog

## v12.3.1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CHANGELOGS should never be manually changed. This is one of those AI-generated PR time waster gripes that maintainers have. Please be more diligent in checking the contents before submitting PRs.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will do. The frustration is understandable, apologies

@newswim

newswim commented May 29, 2026

Copy link
Copy Markdown
Author

@newswim thanks for the PR, but there's a ton of clanker fluff in your PR description. please distill that down. I'd also be interested in seeing the prompt(s) you used to generate this PR.

@shellscape Fair feedback, and I can. For context, I used Claude Code when implementing the fix, but bug surfaced in the wild inside of my team's monorepo. I've been using a workaround in the meantime and wanted to try to get this behavior patched upstream.

As for sharing the prompt, happy to share the design doc if it'd be useful — it has local filesystem paths I'd just want to scrub first.

I have a repro that has more information and a more robust test suite:
https://github.com/newswim/repro-rollup-ts-plugin-config-issue

@newswim newswim requested a review from shellscape May 29, 2026 14:56
@newswim newswim force-pushed the fix/ts-plugin-defaults-respect-extends branch from 98ec0e5 to ce01801 Compare May 29, 2026 15:16
…s wins

DEFAULT_COMPILER_OPTIONS were spread into the leaf tsconfig's compilerOptions slot
passed to ts.parseJsonConfigFileContent, which TypeScript treats as values set
directly on the leaf. That meant the plugin's module: 'esnext' default silently
overrode anything inherited via extends, producing TS5110 under TypeScript 5.x
when a base config set module/moduleResolution to nodenext.

Apply defaults after parseJsonConfigFileContent returns, only for keys the
resolved config left unset. ts.convertCompilerOptionsFromJson coerces JSON
strings ('esnext') to the parsed enum form (ts.ModuleKind.ESNext).

Adds an extends-nodenext fixture plus a version-independent unit test on
parseTypescriptConfig and an end-to-end TS5110 check. Two pre-existing tests
that relied on the buggy default-override behavior now pass module: 'esnext'
explicitly. fakeTypescript helper picks up a convertCompilerOptionsFromJson
stub.

resolves rollup#1726
resolves rollup#1583
@newswim newswim force-pushed the fix/ts-plugin-defaults-respect-extends branch from ce01801 to 2dadbe2 Compare May 30, 2026 02:25
@newswim newswim changed the title fix(typescript): apply plugin defaults after tsconfig parse so extends wins fix(typescript): apply plugin defaults after parsing tsconfig files, honoring extension Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants