Enhancement Request
The automatic project detection in detectTypeScriptImportExtension currently reads tsconfig.json directly but does not resolve the extends field. This means projects using base configurations (e.g., "extends": "@tsconfig/node18/tsconfig.json") won't have their moduleResolution detected if it's defined in the parent config.
Background
Introduced in PR #344, the basic detection works for many cases where moduleResolution is directly in tsconfig.json. However, many real-world TypeScript projects use base configurations via the extends field.
Scope
Add recursive tsconfig resolution to:
- Read the
extends field from tsconfig.json
- Load and parse the base config (can be a local file or npm package)
- Merge
compilerOptions with proper precedence (child overrides parent)
- Support multiple levels of inheritance (base can extend another base)
Example Use Cases
Projects using:
@tsconfig/node18, @tsconfig/node20, etc.
./tsconfig.base.json in monorepos
- Custom shared configs
Implementation Notes
- Handle both relative paths (
./tsconfig.base.json) and npm packages (@tsconfig/node18/tsconfig.json)
- Use proper Node.js resolution for npm packages
- Implement proper merge logic (arrays override, objects shallow merge)
- Add tests for common scenarios
Related
Enhancement Request
The automatic project detection in
detectTypeScriptImportExtensioncurrently readstsconfig.jsondirectly but does not resolve theextendsfield. This means projects using base configurations (e.g.,"extends": "@tsconfig/node18/tsconfig.json") won't have theirmoduleResolutiondetected if it's defined in the parent config.Background
Introduced in PR #344, the basic detection works for many cases where
moduleResolutionis directly intsconfig.json. However, many real-world TypeScript projects use base configurations via theextendsfield.Scope
Add recursive tsconfig resolution to:
extendsfield fromtsconfig.jsoncompilerOptionswith proper precedence (child overrides parent)Example Use Cases
Projects using:
@tsconfig/node18,@tsconfig/node20, etc../tsconfig.base.jsonin monoreposImplementation Notes
./tsconfig.base.json) and npm packages (@tsconfig/node18/tsconfig.json)Related