Skip to content

Generate Typescript  #6145

Description

@ericvergnaud

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).

Activity

  1. tlively commented on Dec 4, 2023

    @tlively
    Member

    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?

  2. ericvergnaud commented on Dec 4, 2023

    @ericvergnaud
    ContributorAuthor

    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.

  3. tlively commented on Dec 4, 2023

    @tlively
    Member
    • 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.

  4. ericvergnaud commented on Dec 4, 2023

    @ericvergnaud
    ContributorAuthor

    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.

  5. tlively commented on Dec 5, 2023

    @tlively
    Member

    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!

  6. ericvergnaud commented on Dec 13, 2023

    @ericvergnaud
    ContributorAuthor

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions