Skip to content

Are TypeScript definitions generated by transpile supposed to include comments from the WIT file? #397

Open

Description

@blaine-arcjet

I found #94 which fixed the TypeScript generation and it mentions comments, but I can't seem to get the comments I defined in my .wit file to actually show up when I use jco transpile. Is this something that is supported?

Activity

  1. guybedford commented on Mar 9, 2024

    @guybedford
    Collaborator

    Yes TypeScript output includes the comments from WIT. If you have an example of what specific doc comments are being missed in translation that would be great to track.

  2. blaine-arcjet commented on Mar 11, 2024

    @blaine-arcjet
    ContributorAuthor

    Interesting! I'm not getting any comments but the current stuff isn't open source. Let me create a reproduction.

  3. sd2k commented on Oct 10, 2024

    @sd2k

    I think I may just have run into this too, perhaps due to bytecodealliance/cargo-component#229? Is there any way of pointing transpile to the original WIT file to get the comments back, since they're not included in the WASM right now?

  4. sd2k commented on Oct 10, 2024

    @sd2k

    Huh, well I found a workaround: after running jco transpile I can run jco types and point it at the original WIT file to get the types with doc comments. For anyone finding this, if you have imports you'll need to add the corresponding WIT files to a deps directory next to the main WIT file, too.

  5. oovm commented on Dec 25, 2024

    @oovm
  6. dgendill commented on Oct 9, 2025

    @dgendill

    I'm also seem to be missing doc comments. Here's my workflow

    Embed WIT into wasm file

    wasm-tools component embed wit/quarto.wit ./target/wasm32-unknown-unknown/release/quarto.wasm -o ./target/wasm32-unknown-unknown/release/quarto.wasm
    

    Create a Web Assembly Component

    wasm-tools.exe component new ./target/wasm32-unknown-unknown/release/quarto.wasm -o ./dist/quarto.wasm
    

    Transpile into JavaScript

    npm run jco -- transpile ./dist/quarto.wasm -o dist/quarto-bindings --map math=./quarto-imports.js
    

    At this point the resulting TypeScript interfaces are missing documentation comments. But if I run the types command seperatly, I can work around this...

    Rebuild the types including documentation comments

    npm run jco -- types wit/quarto.wit -o dist/quarto-bindings
    

    I'm on jco 1.15 and wasm-tools 1.239.0

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