microsoft / microsoft/TypeScript
Add a specific error message for disallowed imports in project references?
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo l'importazione di back-reference nel repository collegato ts-repro-back-reference-import e ispeziona i riferimenti al progetto di tsconfig.json coinvolti. Confronta la diagnostica TS6307 esistente con il contesto aggiuntivo proposto, quindi individua le posizioni nella diagnostica del compilatore TypeScript e nei test che gestiscono l'inclusione dei file di progetto. Il lavoro è completato quando l'importazione errata produce un messaggio specifico e azionabile senza modificare il comportamento valido dei riferimenti al progetto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100