Skip to content

fix(core): prefer later entries of an extends array for cmkOptions - #473

Open
RClaudiuM wants to merge 1 commit into
mizdra:mainfrom
RClaudiuM:fix/453-extends-array-precedence
Open

RClaudiuM wants to merge 1 commit into
mizdra:mainfrom
RClaudiuM:fix/453-extends-array-precedence

Conversation

@RClaudiuM

@RClaudiuM RClaudiuM commented Nov 8, 2026 •

Copy link
Copy Markdown

Fixes #453

What

readConfigFile merged the extended tsconfig files in the flattened order of extendedSourceFiles and never overwrote an option that was already set. For a chain of extends, that order puts the nearest file first, so the precedence was right. For an extends array it let the earliest entry win, while TypeScript lets the latest entry win for compilerOptions.

Now the inherited options are resolved per extends entry. A later entry, together with the files it extends in turn, takes precedence over an earlier one. The file's own cmkOptions still win over everything it extends. Diagnostics are collected the same way as before.

extendedSourceFiles only gives the flattened list, so the direct entries are recovered by skipping the files each entry extends in turn. There is one case this can't tell apart: an entry that also appears earlier in the list because an earlier entry extends it ("extends": ["./a.json", "./c.json"] where a.json extends c.json). That case keeps the old precedence.

Tests

Two tests added to packages/core/src/config.test.ts:

  • prefers a later entry of an `extends` array over an earlier one: the example from the issue (dtsOutDir is now generated2, same source as compilerOptions.module)
  • prefers the tsconfig extended by a later entry of an `extends` array over an earlier entry

Before the fix, both tests fail (dtsOutDir resolves to generated1). After the fix:

  • vp test: 43 files, 502 passed
  • vp check: passes
  • vp run build: passes

I did not run vp run vscode-test locally.

@changeset-bot

changeset-bot Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e4122a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@css-modules-kit/core Patch
@css-modules-kit/ts-plugin Patch
@css-modules-kit/codegen Patch
@css-modules-kit/content-mapper Patch
@css-modules-kit/core-strada Patch
@css-modules-kit/eslint-plugin Patch
@css-modules-kit/stylelint-plugin Patch
css-modules-kit-vscode Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

readConfigFile merged the extended tsconfig files in the flattened order of extendedSourceFiles and never overwrote an option that was already set. That is right for a chain of extends, but for an extends array it let the earliest entry win, while TypeScript lets the latest entry win.

Resolve the inherited options per extends entry instead, so a later entry (and the files it extends) takes precedence over an earlier one.

Fixes mizdra#453
@RClaudiuM
RClaudiuM force-pushed the fix/453-extends-array-precedence branch from 7651013 to e4122a3 Compare November 10, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An earlier entry of an extends array takes precedence over a later one for cmkOptions

1 participant