Skip to content

Add prototype of wasm-bindgen-typescript #228

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

Merged
merged 1 commit into from
Jun 5, 2018

Conversation

spastorino
Copy link
Contributor

@spastorino spastorino commented Jun 4, 2018

This is a first prototype of wasm-bindgen-typescript. The idea is to parse TypeScript definition files and be able to output Rust code from it.
This is kind of WIP, though it work in some cases but far for a finished and polished thing. There are still some things to fix and do.

This thing first use api-extractor (it's an npm package and needs to be installed) to parse the typescript definition file you want to process and saves a json file with the definitions. After that it parses this json file and ends filling wasm-bindgen IR. There's a main (which probably should not be in the project 😄) to run the whole thing and print the Rust source on screen.

Todo

  • It needs to cover all the different data structures that can come on TypeScript files, in particular fa8961e#diff-7837f9f1900f30ff96bd2bbfe07a3f4eR30
  • It needs to run api-extractor passing the -c flag and the right location of api-extractor.json file
  • It needs a lot of test cases to be sure that we end covering all the possible TypeScript constructions
  • Check out tsconfig.json and see if there's something we can do better
  • Check api-extractor.json and see if there's something we can do better
  • It would be nice to evaluate https://github.com/SimplrJS/ts-extractor and consider replacing api-extractor with it. ts-extractor cover more syntaxis and it's more flexible from what I've seen.
  • Probably we would like to refactor this a bit, maybe use a visitor, or implement serialize in a smarter way and dump directly to IR doing smarter stuff if possible or something like that.

@spastorino
Copy link
Contributor Author

/cc @fitzgen @alexcrichton

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! A great starting place for collaboration :)

Thanks @spastorino!

@fitzgen fitzgen merged commit 065a4b2 into rustwasm:master Jun 5, 2018
@fitzgen
Copy link
Member

fitzgen commented Jun 5, 2018

Note: we should also enable tests/building this crate in travis CI -- see the .travis.yml file for how its done for the webidl crate, for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants