Open Danielku15 opened 2 months ago
Referencing some more related issues where a beforeDeclaration hooks would have a benefit:
.js
and d.ts
with transforming the comments (currently d.ts
would be lacking some information)@default
tags (currently the initializers are erased and information is lost).The afterDeclarations
was added in
And another problem:
afterDeclarations
there seems something broken on the AST. parent
is unset for ts.PropertyDeclaration
nodes and both ts.getJSDocCommentsAndTags
and ts.getSyntheticLeadingComments
return nothing. The built-in transforms seem to break things using 5.5.2
. (see here).
🔍 Search Terms
beforeDeclarations declaration transform transformers afterDeclarations
✅ Viability Checklist
⭐ Suggestion
The TypeScript compiler API already supports custom transformers in 3 ways:
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