benjamn / ast-types

Esprima-compatible implementation of the Mozilla JS Parser API
MIT License
1.13k stars 195 forks source link

feat: add overrideDefs function #937

Closed jedwards1211 closed 1 year ago

jedwards1211 commented 1 year ago

Solving https://github.com/benjamn/recast/issues/1283 would be difficult because it imports ast-types everywhere, and I would have to replace those references with passing an ast-types fork as new function parameters all over the place.

This is the pragmatic solution, it would allow me to just replace all of the ast-types exports with my own fork built from @babel/types (see https://github.com/benjamn/ast-types/issues/823). So anywhere that imports them would get my definitions that are up-to-date with babel.

Building defs from @babel/types or other parsers' metadata is the only sustainable option for the community to have a reliable codemod system built on recast.

jedwards1211 commented 1 year ago

Ugh this won't work the best either...I would have to make sure I override the defs before I import recast