Add option to include default typeRoots when overriding typeRoots
## Search Terms default typeRoots ## Suggestion By default, when `typeRoots` is unspecified, TypeScript looks for `node_modules/@types` in the project's directory and all ancestor directories, similar to Node's module resolution algorithm. This is covered in [the tsconfig.json docs](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) and is implemented [here](https://github.com/Microsoft/TypeScript/blob/b534fb4849eca0a792199fb6c0cb8849fece1cfd/src/compiler/moduleNameResolver.ts#L240-L260). When specifying `typeRoots` in tsconfig.json, this overrides the default `typeRoots` entirely. You can include `"node_modules/@types"` in your `typeRoots` array, but that does not include ancestor directories. This is a feature request to provide a way, such as a new option, to include the default type roots in addition to the overridden values. ## Use Cases The primary use case is within a repository using Yarn workspaces. Yarn hoists npm packages to the workspace root. This means you can end up with a directory hierarchy like this: ``` . ├── node_modules │ └── @types │ └── dependency └── packages └── example ├── example.ts ├── package.json └── tsconfig.json ``` If `tsconfig.json` wants to include `node_modules/@types` in the workspace root (in addition to other type declaration directories specified in `typeRoots`), it needs to look like this: ``` { "compilerOptions": { "typeRoots": ["../../node_modules/@types", ...] } } `
Posted by ide on Apr 11, 2019, 1:47 AM
Tags
Related issues
- [Meta] Feedback on granular control over Copilot changes
- unexpected status 401 Unauthorized issue
- [MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
- [CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
- Video stops playing after some minutes
- [MODEL] Claude verbose code comments by default — ignores instructions to stop.
Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments
github (Software)
[Meta] Feedback on granular control over Copilot changes
unexpected status 401 Unauthorized issue
[MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
[CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
Video stops playing after some minutes
[MODEL] Claude verbose code comments by default — ignores instructions to stop.
Scope Codex VS Code chats to the current workspace/project
Update on "Co-authored-by: Copilot" in commit messages
Add option to include default typeRoots when overriding typeRoots
## Search Terms default typeRoots ## Suggestion By default, when `typeRoots` is unspecified, TypeScript looks for `node_modules/@types` in the project's directory and all ancestor directories, similar to Node's module resolution algorithm. This is covered in [the tsconfig.json docs](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) and is implemented [here](https://github.com/Microsoft/TypeScript/blob/b534fb4849eca0a792199fb6c0cb8849fece1cfd/src/compiler/moduleNameResolver.ts#L240-L260). When specifying `typeRoots` in tsconfig.json, this overrides the default `typeRoots` entirely. You can include `"node_modules/@types"` in your `typeRoots` array, but that does not include ancestor directories. This is a feature request to provide a way, such as a new option, to include the default type roots in addition to the overridden values. ## Use Cases The primary use case is within a repository using Yarn workspaces. Yarn hoists npm packages to the workspace root. This means you can end up with a directory hierarchy like this: ``` . ├── node_modules │ └── @types │ └── dependency └── packages └── example ├── example.ts ├── package.json └── tsconfig.json ``` If `tsconfig.json` wants to include `node_modules/@types` in the workspace root (in addition to other type declaration directories specified in `typeRoots`), it needs to look like this: ``` { "compilerOptions": { "typeRoots": ["../../node_modules/@types", ...] } } `
Comments (0)
No comments yet. Start the discussion.