Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tsconfig extends resolution doesn't respect "tsconfig" key in package.json #3247

Closed
bgotink opened this issue Jul 18, 2023 · 3 comments
Closed
Labels

Comments

@bgotink
Copy link

bgotink commented Jul 18, 2023

As part of resolving "extends" in tsconfig files, typescript looks for the "tsconfig" key in the package.json file. Esbuild instead looks for a few locations.

Our base tsconfig is called tsconfig.base.json as it's not meant to be picked up by typescript directly but via other tsconfigs that extend it. Our package.json includes "tsconfig": "./tsconfig.base.json", but esbuild doesn't pick that up.

https://github.com/microsoft/TypeScript/blob/4879087bef68e24ec2f7c98d83d70a88a5cc18c4/src/compiler/moduleNameResolver.ts#L377-L379

filesToCheck := []string{r.fs.Join(join, "tsconfig.json"), join, join + ".json"}

@evanw
Copy link
Owner

evanw commented Jul 18, 2023

Huh, today I learned. Where is that documented on https://www.typescriptlang.org/? I can't find any documentation about this. The only thing I found was this open issue which appears to be a request for a feature that doesn't exist.

@evanw evanw added the tsconfig label Jul 18, 2023
@bgotink
Copy link
Author

bgotink commented Jul 19, 2023

The only documentation I can find is in the typescript 3.2 release notes:

For each of those packages, TypeScript will first check whether package.json contains a "tsconfig" field, and if it does, TypeScript will try to load a configuration file from that field. If neither exists, TypeScript will try to read from a tsconfig.json at the root.

@evanw
Copy link
Owner

evanw commented Jul 20, 2023

Thanks for the link. So it sounds like this only happens when you reference a package name via extends. In that case esbuild should check that package's package.json file for a tsconfig field. The relevant issue and PR is microsoft/TypeScript#18865 and microsoft/TypeScript#27348.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants