mizdra / mizdra/css-modules-kit

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

Open
#453 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Priority: Low Type: Bug
Dominant language
TypeScript
Stars
197
Forks
15
Avg merge
1h 33m
Merged PRs (30d)
9

Description

Summary

When extends in tsconfig.json is an array, cmkOptions of an earlier entry take precedence over those of a later entry. TypeScript resolves the same conflict in the opposite way: the later entry wins.

Details

tsconfig.base1.json:

{
  "compilerOptions": { "module": "esnext" },
  "cmkOptions": { "dtsOutDir": "generated1" }
}

tsconfig.base2.json:

{
  "compilerOptions": { "module": "es2015" },
  "cmkOptions": { "dtsOutDir": "generated2" }
}

tsconfig.json:

{
  "extends": ["./tsconfig.base1.json", "./tsconfig.base2.json"]
}

Result of readConfigFile:

Option Value Taken from
compilerOptions.module (resolved by TypeScript) ES2015 tsconfig.base2.json
dtsOutDir (resolved by css-modules-kit) <rootDir>/generated1 tsconfig.base1.json

readConfigFile merges the options of the extended files in the order TypeScript lists them, and an option that is already set is never overwritten. This gives the right precedence for a chain (tsconfig.jsonbase2base1), but the wrong one for an array.

Expected behavior

dtsOutDir is <rootDir>/generated2. For every option of cmkOptions, a later entry of the extends array takes precedence over an earlier one, as TypeScript does for compilerOptions.


🤖 Generated with Claude Code

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at readConfigFile, using the three tsconfig.json examples in the issue to reproduce the precedence difference between an extends array and a chain. Inspect how extended options are merged, then verify that the later array entry supplies dtsOutDir while preserving TypeScript's compilerOptions behavior. Done means the result resolves dtsOutDir to /generated2.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.