microsoft / microsoft/TypeScript
Intellisense import suggestions - search index files only
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Hi guys, in large codebases I often encounter following issue:
I work with React/TypeScript combo. If I export something from a file, it's visible to the entire project and Intellisense auto-import feature suggests me all functions/classes/... exported. It's overwhelming to list through all exports, especially in large projects, where different entities can have the same name. I would love to create some sort of hierarchy with use of index files. Auto-import would implicitly "see" only exports within the same folder or siblings of current folder (recursively) if they have exports declared in index file.
Example:
/src
/module-alpha
/components
Alpha.tsx
List.tsx
Detail.tsx
index.ts --> export {default} from './Alpha.tsx'
/model
utils.ts
index.ts --> export * as Utils from './utils'
ModuleAlpha.tsx
index.ts --> export {default} from './ModuleAlpha.tsx'
/module-beta
/components
Beta.tsx
List.tsx
Detail.tsx
index.ts --> export {default} from './Beta.tsx'
/model
utils.ts
index.ts --> export * as Utils from './utils'
ModuleBeta.tsx
index.ts --> export {default} from './ModuleBeta.tsx'
If I am in file /src/module-alpha/components/Alpha.tsx and I type Detail, I want the auto-import to suggest me just Detail within the current folder. In this context I would be able to "see":
ListandDetailfrom current folderUtilsfrom/modelwithin this moduleModuleAlphaModuleBeta
In other words - folder will behave like a file. If you want the entity to be visible outside the folder, you would have to explicitly define the export in the index file (recursively). I hope that it's clear.
I don't want to change the ES6 module system, and we could still import the entity manually. I just want the intellisense to suggest me only relevant things.
Is this something that can be done?
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 existing IntelliSense auto-import behavior and how TypeScript resolves exports from index files. Compare suggestions for the described module-alpha and module-beta structure. Done means suggestions are limited by recursively declared index-file exports while manual imports remain available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100