Skip to content

TypeScript: expand ${configDir} in inherited tsconfig paths #13

Closed

Description

@0xfauzi

Problem

tsconfig.json allows the variable ${configDir} in path options such as outDir, rootDir, baseUrl and paths. It stands for the directory of the top-level config file, so a shared base config can point at the project that extends it. The TypeScript reader in #12 reads these options but does not expand the variable.

What happens

sindresorhus/ky at 0d59458a0a extends @sindresorhus/tsconfig, whose tsconfig.json has:

"outDir": "${configDir}/distribution"

With node_modules present, load_typescript_config returns out_dir as:

<repo>/node_modules/@sindresorhus/tsconfig/${configDir}/distribution

That directory does not exist, so the compiled-target mapping from outDir back to rootDir cannot fire.

Why it does not show today

ky's seven entry points are still found, because the fallback added in #12 (a distribution/ target maps to a unique source/ file) covers this case. So the facts are right for ky. A project whose source root is not src/ or source/, or whose base config sets paths with ${configDir}, would get a wrong or missing mapping with no line saying so.

Fix

In typescript_config.py, when reading a path option from any file in the extends chain, replace ${configDir} with the directory of the top-level tsconfig.json before resolving it. The TypeScript documentation for ${configDir} is the reference for the rule.

Acceptance

Written before the change:

  • On ky at the pinned commit with node_modules installed, out_dir resolves to <repo>/distribution.
  • A fixture whose base config sets "paths": { "@/*": ["${configDir}/src/*"] } resolves @/lib/util to the source module.
  • The seven-repository run in bench/typescript_adapter.py produces the same numbers as the run recorded on Add TypeScript extraction, change, and history support #12.

Found while reviewing #12. Not blocking that PR.

Activity

  1. added a commit that references this issue on Sep 26, 2026
    2dcd17e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions