dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`paths` is not recognized when defined in a config via `extends`

saevarb opened this issue · comments

Given two tsconfig.json files as follows

// foo/tsconfig.json
{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    ...
    "paths": {
      "~/*": ["src/*"]
    }
  },
  ...
}

// service/tsconfig.json
{
  "$schema": "https://json.schemastore.org/tsconfig",
  "extends": "foo/tsconfig.json",
  "compilerOptions": {
    "baseUrl": ".",
    "outDir": "./dist"
  },
  "include": [
    "src"
  ]
}

I.e. one shared base config where paths is defined and another that extends that base config to use in a specific project, tsconfig-paths does not properly recognize paths as defined. In order for it to recognize them, they need to be defined in the service/tsconfig.json, which does not align with how typescript does it. tsc will happily compile programs with the path mapping in the shared config, and it also outputs it when running tsc --showConfig in the service project, and incidentally, esbuild also happily resolves them as expected.