microsoft / microsoft/TypeScript
Support for directory named module
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
When creating an application that follows atomic design, you usually want to create 1 folder per module, this folder containing both the tsx file and the scss file.
The issue is that, right now you're forced to either name your tsx files "index.tsx", so that you can import them using 'import "/path/to/DirectoryName"', but then it means that every single file module file in your project now have the same "index.tsx" name, which is a pain.
The other solution is to name your component files the same name as the folder, but now you have to specify the file name in the import. Exemple : 'import "/path/to/DirectoryName/DirectoryName".
But now you have import statements that are longer than needed, and it doesn't force you to name your tsx file correctly (unless you use CI), because it's not a default name anymore.
To have the best of both wold, we'd need for the default name to be either index.tsx or DirectoryName.tsx, so that we can do 'import "/path/to/DirectoryName"' to import /path/to/DirectoryName/DirectoryName.tsx
Webpack already supports this through this plugin : https://www.npmjs.com/package/directory-named-webpack-plugin (25k weekly downloads), so you can get an application that works using this kind of imports.
But the IDE's can't resolve the directory named imports, mostly because TS doesn't support it.
Adding support to this would be greatly appreciated.
This is been an issue for quite a long time, as been documented here : https://github.com/microsoft/TypeScript/issues/24116
This linked above issue also contains a proposed solution by @tylerkayser
@gaui 's comment summarizes that well : https://github.com/microsoft/TypeScript/issues/24116#issuecomment-399724546
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 leyendo el issue de TypeScript #24116 enlazado y la solución propuesta en el comentario referenciado; después, compara el comportamiento solicitado con el diseño existente de resolución de módulos. Se considera terminado cuando una importación de un directorio resuelve su archivo TSX con el mismo nombre sin requerir el nombre de archivo, manteniendo el comportamiento existente de index.tsx.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- 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
- 35/100