-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert @babel/parser
to TypeScript
#14783
Conversation
yarn dlx flowts --no-allow-js --interactive-rename -i "./src/**/*.js" "./packages/babel-parser/" && yarn eslint packages/babel-parser '**/*.ts' --fix
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52583/ |
Amazing PR and at the same time CI is completely green, I like it very much! |
?{ code?: ParseErrorCode, reasonCode?: string } | boolean, | ||
function toParseErrorCredentials( | ||
b: string, | ||
a?: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export
was added before the comment, which seems to be a problem with the automatic conversion.
update: I tried to pick the code block and it failed, see the code before and after here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, awesome! I pushed a commit undoing some minor format changes.
In this PR we converts
babel-parser
to TypeScript, which marks an end of the transition from Flow (but not the end of improving the codebase typings). I tried to make this PR as small as possible. For those typing errors which can't be fixed at my first glance, I suppress them with@ts-expect-error
. Hopefully we will remove most of them when we further improve the parser typings.Significant changes:
Undone
type marker is introduced for those intermediate AST nodes created bystartNode
Accessing the
type
property is a typing error so we are sure that we didn't do any type differentiation on unfinished AST nodes, otherwise the other properties are typed as the AST definitions in "babel-parser".this.someParserMethod
which is not overridden in the plugin, we usesuper.someParserMethod
instead.Further Improvements that be landed in separate PRs:
@babel/parser
AST types to@babel/types
AST types@ts-expect-error
commentsThis PR revives #13370. I should also thank @zxbodya, who maintains the
flowts
which helps the transition process.