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

Begin evaluating parsing TypeScript with Babylon #2334

Open
JamesHenry opened this issue Jun 28, 2017 · 8 comments

Comments

@JamesHenry
Copy link
Collaborator

commented Jun 28, 2017

The TypeScript Team (specifically @andy-ms) has done an amazing job adding initial support for parsing TypeScript using Babylon.

The PR was just merged into master here: babel/babylon#523

I have been working with Andy for a while on trying to align the AST produced by typescript-eslint-parser with what will be produced by the Babylon TypeScript plugin.

I have a dedicated repo for tracking that work here: https://github.com/JamesHenry/tsep-babylon-test

Notes:

  • I am sure there will still be plenty of differences between the two ASTs at this stage, we will work together to slowly close these gaps
  • There will likely still need to be some iteration on the Babylon TypeScript plugin - prettier tests will hopefully help a lot with this

cc @DanielRosenwasser

@vjeux

This comment has been minimized.

Copy link
Collaborator

commented Jun 28, 2017

I'm 100% onboard getting prettier to support both tsep and babylon-typescript! If you want to add a new parser type and the tests running inside of prettier, I'm supportive :)

@JamesHenry

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 28, 2017

That would be absolutely ideal, thanks a lot!

@JamesHenry

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 28, 2017

Very quickly hacked everything together (temporarily using Babylon TypeScript plugin as a straight replacement) to get an idea of the starting point:

screen shot 2017-06-28 at 16 44 50

Plenty for me to dig into 😄

@azz

This comment has been minimized.

Copy link
Member

commented Jun 28, 2017

Stupid question, can both the flow and typescript plugins be turned on simultaneously?

@JamesHenry

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 28, 2017

Babylon will throw in that case https://github.com/babel/babylon/blob/master/src/index.js (couldn't easily link line number as on mobile)

@azz

This comment has been minimized.

Copy link
Member

commented Jun 29, 2017

That's completely sensible!

@JamesHenry

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 11, 2017

I spent a while this evening plugging in both TS parsers into the tests in order to begin narrowing down the differences. I will keep things on my branch for now, as it significantly increases the number of tests (and therefore the test execution time) and is still very much a WIP.

For reference, the tests that are currently broken using babel-typescript-plugin:

  • class_comment
  • trailing_whitespace
  • typescript_export
  • typescript_import_require
  • typescript_interface
  • typescript_method
  • typescript_module
  • typescript_nosemi

I will identify the underlying AST differences causing these issues and then work with Andy and Daniel (TypeScript Team) to align. Some of them may have already been identified in my repo and just need to be resolved.

@JamesHenry

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 12, 2017

Found a little more time today - resolving JamesHenry/tsep-babylon-test#9 will allow me to address the issue with trailing_whitespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.