Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c5c78ab:
|
3c5c918 to
08596fe
Compare
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/48162/ |
3b8b2f3 to
c5c78ab
Compare
I agree, object literals are faster than a class, but we can not use object literal in Babel 7 because of the undocumented
Agreed. The fastest approach is to generate AST node from object literals, like kataw did in AST builders: https://github.com/kataw/kataw/blob/main/src/ast/expressions/array-literal.ts. |
…initions, fix issues found
Originally this was a part of #11578 however it was decided better to do it separately, because it looks to be bigger refactoring(not just converting it to typescript).
This is still very much in progress - and is just a starting point, to start experimenting with next steps.
Remaining issues, to solve:
The problem is that currently parser typically starts with node which does not yet have a specific node type, and then adds more properties to it or removes some of them, to eventually get final node type.
Often it looks like this:
TypeScript does not work well with that approach… Also, there might be some space for optimization, not sure but I guess it might be faster to have constructor or object literal
src/typesNode types there are incomplete, and in some cases were effectively same as
anyfor type-checks with flow… I tried to fix it, however I guess -@babel/typesprobably should be used instead or to add some code generation for parser as well.Suggestion - to try doing something like this instead:
This would be much better for type-checking, and will require less manual type annotations.
However about builders - probably this might require some changes for generated builders in
@babel/typesif to used them - I worry, they might be slow, In particular - I think we might want to remove or disable runtime parameter validation(not actually sure how beneficial that would be…), and generally make them less dynamic instead generating more code.Drafted changes for
@babel/typeshere #13369