microsoft / microsoft/TypeScript
Add a specific error message for disallowed imports in project references?
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
Suggestion
🔍 Search Terms
project reference back import
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
After introducing project references to a monolith repo with many developers, I've sometimes seen confusion over people writing imports from projects in the incorrect direction: e.g. if project B has a tsconfig reference to project A, trying to import from B in A. ♻️
https://github.com/JoshuaKGoldberg/ts-repro-back-reference-import
Here's an example error message that says what's technically wrong but doesn't give much context:
src/a/index.ts:1:19 - error TS6307: File '---/src/b/index.ts' is not listed within the file list of project '---/src/a/tsconfig.json'. Projects must list all files or use an 'include' pattern.
1 import { b } from "../b";
~~~~~~
📃 Motivating Example
Adding a specific error for these incorrect direction ("back") imports might help folks new to project references understand what they're doing wrong:
src/a/index.ts:1:19 - error TS6307: File '---/src/b/index.ts' is not listed within the file list of project '---/src/a/tsconfig.json'. Projects must list all files or use an 'include' pattern.
File "---/b/index.ts" is included in "---/b/tsconfig.json", but "---/a/tsconfig.json" does not list a reference to "---/b/tsconfig.json".
1 import { b } from "../b";
~~~~~~
💻 Use Cases
https://github.com/JoshuaKGoldberg/ts-repro-back-reference-import
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 reproduciendo la importación de back-reference en el repositorio vinculado ts-repro-back-reference-import e inspecciona las referencias de proyecto de tsconfig.json implicadas. Compara el diagnóstico TS6307 existente con el contexto adicional propuesto y, después, identifica las ubicaciones del diagnóstico del compilador de TypeScript y de las pruebas que gestionan la inclusión de archivos de proyecto. Se considera terminado cuando la importación incorrecta produce un mensaje específico y accionable sin cambiar el comportamiento válido de las referencias de proyecto.
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
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100