microsoft / microsoft/TypeScript
Configurable import suggestions to override global types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Search Terms
Suggestion
In our code base we have a module export called Option which we use very often.
However, if we try to reference Option in a module where it's not currently imported, we will not get import suggestions/fixes for this.
This is because there is already a (different) global type of the same name, provided by the dom lib types.
I would like to be able to configure TypeScript and/or VS Code so that I do have import suggestions for Option.
Suggestion: any time a module references a global value, and the project has a module export of the same name, provide an import suggestion for that.
Potential caveat of this suggestion: what happens when you select "add all missing imports"? Ideally I would want it to import my Option, but what if I intentionally wanted to use the global version instead?
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the requested TypeScript and/or VS Code import-suggestion behavior for a module export that shares a name with a global DOM type. Define how explicit suggestions and "add all missing imports" should choose between the module export and global version. Done means the behavior is configurable and the intentional global-use case remains clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100