microsoft / microsoft/TypeScript
Intellisense import suggestions - search index files only
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 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?
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par examiner le comportement existant d’IntelliSense pour les importations automatiques et la manière dont TypeScript résout les exportations des fichiers index. Comparez les suggestions pour la structure décrite de module-alpha et module-beta. La tâche est terminée lorsque les suggestions sont limitées par les exportations déclarées récursivement dans les fichiers index, tandis que les importations manuelles restent disponibles.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- react, typescript
- Domaine
- developer-experience, tooling
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 28/100