microsoft / microsoft/TypeScript
Typecheck multiple module formats at once
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
(The other side of #15833)
Search Terms
typecheck multiple module formats
Suggestion
For projects that compile to multiple output formats - e.g. different module outputs - it would be useful to have typechecking able to emit errors for multiple formats at once.
The reason that duplicate typechecking is needed is that typechecking is slightly different based on the module - e.g. for commonjs / AMD, export = and import foo = require(...) are both legal, whereas in ESNext they are not; ESNext has import.meta and in some cases, top level await, that AMD/Commonjs don't support. So no single module target has the strictest typechecking.
The benefits are:
- save CPU time
- no need for running typecheck multiple times and get most errors duplicated between them
On it's own, I'm not sure it'll make a ton of sense - e.g. in compilerOptions the module field could take an array of modules, or we could use a new field for this; though together with emit for multiple module types (#15833) we could keep the invariant that tsc typechecks with the same module(s) that it emits.
Use Cases
If I compile my code to both AMD and ESNext, typechecking only as AMD or only as ESNext, does not guarantee my code is valid for the other module format - an export = will fail ESNext typechecking, whereas an import.meta will fail AMD typechecking; so there's no single strictest typecheck mode; as is to guarantee correctness, I need to typecheck against all the module formats we emit, and then any type errors in e.g. function bodies would get repeated in both typechecks. Deduping these errors would be the main benefit.
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 esaminando l’issue correlata #15833 e la gestione esistente di compilerOptions.module. Definisci come configurare e verificare i tipi di più formati di moduli insieme, inclusa la gestione degli errori duplicati; il lavoro è completo quando la proposta supporta i casi indicati di AMD, CommonJS ed ESNext senza richiedere esecuzioni separate del controllo dei tipi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100