Skip to content
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

Merged
merged 5 commits into from
Sep 3, 2018
Merged

@babel/parser: expose a TypeScript definition file from package #8170

merged 5 commits into from
Sep 3, 2018

Conversation

AviVahl
Copy link
Contributor

@AviVahl AviVahl commented Jun 14, 2018

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.

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.
@babel-bot
Copy link
Collaborator

babel-bot commented Jun 14, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8392/

@AviVahl
Copy link
Contributor Author

AviVahl commented Jun 24, 2018

Hey babel team,
Could anybody check this out?
Would be great to get built-in type checking for the next 7 beta :)

@AviVahl
Copy link
Contributor Author

AviVahl commented Aug 27, 2018

@hzoo any chance this could be reviewed/merged in time for the 7.0.0 stable release?

@43081j
Copy link
Contributor

43081j commented Sep 2, 2018

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 @babel/types, you will have to go back to @types/babel-types.

Copy link
Member

@xtuc xtuc left a 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.

@xtuc xtuc added PR: Internal 🏠 A type of pull request used for our changelog categories pkg: parser labels Sep 3, 2018
@xtuc
Copy link
Member

xtuc commented Sep 3, 2018

A Flow to TypeScript transpiler would be very usefull, since Babel has the support for both, it should be pretty easy :)

@xtuc xtuc merged commit fc9becf into babel:master Sep 3, 2018
@AviVahl
Copy link
Contributor Author

AviVahl commented Sep 3, 2018

Thanks for merging!

@mgroenhoff
Copy link
Contributor

Is anyone already removing the typings for babel__parser on DefinitelyTyped?
https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel__parser

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants