bun icon indicating copy to clipboard operation
bun copied to clipboard

Support `extends` in `tsconfig.json`

Open kylecarbs opened this issue 3 years ago • 11 comments

When using paths in tsconfig.json to reference files in outer directories, the compiler fails to resolve:

{
  "compilerOptions": {
    "paths": {
      "lib/ts/*": ["./lib/ts/*"]
    }
  }
}
error: Could not resolve: "lib/coderapi/legacy". Maybe you need to "npm install" (or yarn/pnpm)?

import { License, updateLicense } from "lib/coderapi/legacy"

kylecarbs avatar Nov 30 '21 14:11 kylecarbs

Have you tried setting baseUrl? For example:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "lib/ts/*": ["./lib/ts/*"]
    }
  }
}

Jarred-Sumner avatar Nov 30 '21 21:11 Jarred-Sumner

Yup. Our tsconfig.json uses the extends property to a higher-level directory... maybe that's the problem?

kylecarbs avatar Nov 30 '21 21:11 kylecarbs

maybe that's the problem?

Most likely. extends is not implemented yet, and won't be a priority for ~a month probably.

If you try (temporarily) inlining what extends would do into the tsconfig.json, does that fix it?

Jarred-Sumner avatar Nov 30 '21 21:11 Jarred-Sumner

to reference files in outer directories

I was wondering if this was the issue, but it doesn't seem to be.

When above-the-root references a specific file: image

When above-the-root references a folder: image

Jarred-Sumner avatar Nov 30 '21 22:11 Jarred-Sumner

Ahh I appreciate the investigation. I'll update the title/description, or feel free to close if it's already planned.

kylecarbs avatar Nov 30 '21 23:11 kylecarbs

There isn't an issue tracking extends support currently, so this can be that issue

Jarred-Sumner avatar Nov 30 '21 23:11 Jarred-Sumner

Is this work currently planned? I'd love to integrate this into my repo at work, but we heavily rely on extends in tsconfig

microsoftly avatar Jul 06 '22 02:07 microsoftly

Jarred,

Thanks for all the hard work on this incredible tool. I was playing around with converting my nx monorepo to bun and ran into this issue. Where I have a base tsconfig.json in the root of my monorepo and my react apps under an apps folder that extend from the base. Looking forward to when this issue can be prioritized. Just posting this to help gauge use case and interest. Thanks.

StephenStrickland avatar Jul 06 '22 02:07 StephenStrickland

Another vote for this issue - we have a frontend monorepo which makes heavy use of extended tsconfigs. We also use custom module resolution, which ought to work via tsconfig paths, but the path mapping is defined in some shared/extended config files.

yepitschunked avatar Jul 06 '22 19:07 yepitschunked

Hi!

Is the difficulty here knowing which values extends includes, as well as what value to use when expanding relative paths?

Would porting an existing solution to Zig be a solution to this? https://github.com/privatenumber/get-tsconfig

Is this project something somebody new to Zig could take on?

Thanks for creating Bun and any insights that could help with this work!

dylang avatar Jul 11 '22 19:07 dylang

Excited about Bun, but... also blocked on this!

joshhansen avatar Aug 03 '22 04:08 joshhansen

This was added months ago and I forgot to close the issue

Jarred-Sumner avatar Oct 19 '22 23:10 Jarred-Sumner