microsoft / microsoft/TypeScript
Add support for beforeDeclarations
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔍 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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die bestehenden Varianten benutzerdefinierter Transformer der TypeScript compiler API zu überprüfen, insbesondere die before- und after-Phasen der Deklarationstransformation, die im Issue beschrieben sind. Vergleiche ihre öffentlichen API-Strukturen und bestimme, wie eine beforeDeclarations-Phase hineinpassen würde. Als abgeschlossen gilt die Aufgabe, wenn benutzerdefinierte Transformer auf den vortransformierten AST für die Generierung von Deklarationen zugreifen können und die motivierenden Anwendungsfälle unterstützt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100