microsoft / microsoft/TypeScript
Intellisense import suggestions - search index files only
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
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?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das bestehende IntelliSense-Verhalten für automatische Importe und die Art und Weise zu überprüfen, wie TypeScript Exporte aus index-Dateien auflöst. Vergleiche die Vorschläge für die beschriebene Struktur von module-alpha und module-beta. Als abgeschlossen gilt die Aufgabe, wenn Vorschläge durch rekursiv deklarierte Exporte aus index-Dateien begrenzt sind, während manuelle Importe weiterhin verfügbar bleiben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- react, typescript
- Bereich
- developer-experience, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 28/100