microsoft / microsoft/TypeScript
Intellisense import suggestions - search index files only
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
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?
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza revisando el comportamiento existente de IntelliSense para las importaciones automáticas y cómo TypeScript resuelve las exportaciones de los archivos index. Compara las sugerencias para la estructura descrita de module-alpha y module-beta. Se considera completado cuando las sugerencias están limitadas por las exportaciones declaradas recursivamente en los archivos index, mientras que las importaciones manuales siguen estando disponibles.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- react, typescript
- Área
- developer-experience, tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 28/100