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

Generate Typescript #6145

Closed
ericvergnaud opened this issue Dec 4, 2023 · 6 comments
Closed

Generate Typescript #6145

ericvergnaud opened this issue Dec 4, 2023 · 6 comments

Comments

@ericvergnaud
Copy link
Contributor

Hi,
thanks for the great work.
It seems that emscripten can now generate TypeScript ? See https://emscripten.org/search.html?q=typescript&check_keywords=yes&area=default ?
Would it make sense for binaryen to generate TypeScript instead of JavaScript ?
This would eliminate the risk of gaps between binaryen and binaryen.js.
Happy to try and make that happen if it makes sense (and I can get minimal support).

@tlively
Copy link
Member

tlively commented Dec 4, 2023

Emscripten doesn't really generate typescript, but rather a separate typescript definitions file that helps call Emscripten-generated JS from TS projects.

I'm not sure if you're thinking of compiling binaryen.js to TS or of implementing a wasm2ts tool that complements wasm2js. The former isn't possible because Emscripten doesn't emit typescript, although perhaps we could have it emit a TS definitions file for binaryen.js. The latter doesn't seem too useful because the TS output would only have extremely low level types that wouldn't be very useful for TS programmers.

Maybe the most useful thing to do here would be to create a TS definitions file for the binaryen.js API?

@ericvergnaud
Copy link
Contributor Author

ericvergnaud commented Dec 4, 2023

I'm not thinking about the how yet, just about the what i.e. have a single source of truth and move it as close as possible upstream.

Right now, as I understand it, we have:

  • a js file hosted in Emscripten repo that is post-processed by being simply appended to the binaryen_js.js file produced by Emscripten
  • a d.ts file hosted in Binaryen.js repo that wraps the generated binaryen_js.js.

In an ideal world, we'd have a single Binaryen.ts file, hosted in Binaryen repo, and that would produce a binaryen_js.js and a binaryen_js.d.ts files. Then any change in binaryen would only require updating that Binaryen.ts file. The role of the Binaryen.js repo would then shrink a bit to what it claims to be: a build bot.

I don't yet know how to achieve that but if binaryen committers like the idea I'm happy to give it a try.

@tlively
Copy link
Member

tlively commented Dec 4, 2023

  • a js file hosted in Emscripten repo that is post-processed by being simply appended to the binaryen_js.js file produced by Emscripten

What file is this? Do you mean binaryen.js-post.js hosted here in the Binaryen repo?

In an ideal world, we'd have a single Binaryen.ts file, hosted in Binaryen.js repo, and that would produce a binaryen_js.js and a binaryen_js.d.ts files

Are you referring to this binaryen.js repo? https://github.com/AssemblyScript/binaryen.js/

That repo is downstream from Binaryen and not maintained by us, so the base binaryen.js build from this repo should not depend on it.

@ericvergnaud
Copy link
Contributor Author

ericvergnaud commented Dec 4, 2023

What file is this? Do you mean binaryen.js-post.js hosted here in the Binaryen repo?

Yes

Are you referring to this binaryen.js repo? https://github.com/AssemblyScript/binaryen.js/

Oops typo. Just fixed it.

@tlively
Copy link
Member

tlively commented Dec 5, 2023

Ok, IIUC, you're proposing to add TS definitions to the upstream binaryen.js build here in the Binaryen repo. If so, that sounds good to me!

@ericvergnaud
Copy link
Contributor Author

@tlively I just submitted the PR, so closing this.

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

No branches or pull requests

2 participants