microsoft / microsoft/TypeScript
Autoimport: Prefer Secondary Entrypoint
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Suggestion
🔍 Search Terms
- secondary auto import
✅ Viability 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, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
When auto importing it would be nice if the importer prefered secondary entry points instead of main entry point, as it gets tiresome having to modify or manually write the imports to use a secondary entry point.
Note: It does use the secondary entrypoint if it has already been defined in the file. However, this is for on initial import.
📃 Motivating Example
This allows compilers (such as webpack) to tree-shaking. If including the main entry point all modules get included in the build (for libraries that have them all exported in the main entry point) whereas importing secondary entry points only includes (usually) parts of the library.
💻 Use Cases
Workaround: Manually updating every import every time.
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
No files, tests, or entry points are named. Start by locating TypeScript's auto-import implementation and compare initial import selection with the existing behavior when a secondary entry point is already present. Done means initial auto-imports prefer appropriate secondary entry points without changing runtime behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100