-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
@babel/parser: expose a TypeScript definition file from package #8170
Conversation
This allows the new parser package to be used in TypeScript projects, with static type checking and auto-completions. IDEs like VSCode will use this to show auto completions even in JavaScript projects, which is a huge benefit to users wanting to use the parser directly. This PR follows the auto-generated .d.ts that was added to @babel/types in #7101 - took outdated DefinitelyTyped babylon .d.ts and updated it using new site's documentation. - added "typings" folder to package, with the new .d.ts - connected new .d.ts via package.json's "types" field. also adjusted "files" so folder will be published. - definition file uses TypeScript 2.9's new `import('package').Type` syntax.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8392/ |
also change parameter name to match docs
Hey babel team, |
@hzoo any chance this could be reviewed/merged in time for the 7.0.0 stable release? |
It would be incredibly useful to get this merged and eventually achieve the same goal for all other packages, too. At the minute you can't mix and match DT types as they will conflict. If using the traverse package for example, you will not be able to use the community types combined with |
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.
Sorry, it seems that I missed that before.
I agree that this would be very useful. Unfortunately, I think that we won't be able to maintain it, it would be great if you can report any mistakes/outdated def here.
A Flow to TypeScript transpiler would be very usefull, since Babel has the support for both, it should be pretty easy :) |
Thanks for merging! |
Is anyone already removing the typings for |
This allows the new parser package to be used in TypeScript projects, with static type checking and auto-completions. IDEs like VSCode will use this to show auto completions even in JavaScript projects, which is a huge benefit to users wanting to use the parser directly.
This PR follows the auto-generated .d.ts that was added to @babel/types in #7101
import('package').Type
syntax.