microsoft / microsoft/TypeScript
Add support for beforeDeclarations
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔍 Search Terms
beforeDeclarations declaration transform transformers afterDeclarations
✅ Viability Checklist
- 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 isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
The TypeScript compiler API already supports custom transformers in 3 ways:
- Before built-in .js transformations
- After built-in .js transformations
- After built-in .d.ts transformations
But the API is missing a "Before built-in .d.ts transformations" variant.
📃 Motivating Example
To generate type declarations more dynamically, you often need to access AST nodes of your codebase as it is written. The built-in transformers erase already a lot of the AST making this information unavailable. With the help of this new beforeDeclarations you are able to access your full AST and use it to auto-generate your typescript declaration files.
💻 Use Cases
- Use information from property initializers to include "default values" your JSDoc comments. (see #41486).
- Remove declarations using information like visibility modifiers or used functions in your code to not expose implementation details.
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 le varianti esistenti dei transformer personalizzati della TypeScript compiler API, in particolare le fasi before e after della trasformazione delle dichiarazioni descritte nell’issue. Confronta le forme delle loro API pubbliche e determina come si integrerebbe una fase beforeDeclarations. Il lavoro è completato quando i transformer personalizzati possono accedere all’AST pre-trasformazione per la generazione delle dichiarazioni e i casi d’uso alla base della richiesta sono supportati.
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