Skip to content

fix(graph): bump deno_graph to 0.108.2 for wasm multi-value return types - #34070

Merged
bartlomieju merged 2 commits into
mainfrom
orch/issue-81
May 15, 2026
Merged

bartlomieju merged 2 commits into
mainfrom
orch/issue-81

Conversation

@lunadogbot

Copy link
Copy Markdown
Contributor

Summary

Bumps deno_graph from =0.108.1 to =0.108.2, which picks up
denoland/deno_graph#644
("fix: support wasm multi-value types").

Without this fix, importing a WebAssembly function whose signature has multiple
return values (e.g. (result i32 i32)) generates a TypeScript declaration whose
return type collapses to a single number instead of the expected tuple
[number, number], so deno check reports an incorrect type.

Changes

  • Cargo.toml: deno_graph = { version = "=0.108.2", default-features = false }
  • Cargo.lock: refreshed via cargo update -p deno_graph

No other workspace crate pins deno_graph directly. The 0.108.1 to 0.108.2 diff
is a one-file fix to src/source/wasm.rs plus test fixture updates and does not
change the public API, so no source changes are needed in this repo. The wasm
multi-value behavior is already covered by tests in deno_graph itself.

Verification

cargo check --bin deno passes cleanly against the new release.

Reproduction from the upstream issue:

mkdir /tmp/wasm-multi-value && cd /tmp/wasm-multi-value
deno run --allow-read --allow-write --allow-env - <<'JS'
import wabtMod from "npm:wabt@1.0.36";
const wabt = await wabtMod();
const wat = `(module
  (func $add_and_sub (param $a i32) (param $b i32) (result i32 i32)
    local.get $a local.get $b i32.add
    local.get $a local.get $b i32.sub)
  (export "add_and_sub" (func $add_and_sub)))`;
const mod = wabt.parseWat("t.wat", wat, { multi_value: true });
await Deno.writeFile("test.wasm", mod.toBinary({}).buffer);
JS

cat > test.ts <<'TS'
import { add_and_sub } from "./test.wasm";
const r: "expected-tuple" = add_and_sub(1, 2);
TS

./target/debug/deno check test.ts

With this PR, the inferred return type is now [number, number] rather than number.

Fixes #34065

Closes bartlomieju/orchid-inbox#81

Picks up denoland/deno_graph#644, which fixes `wasm_module_to_dts` so
WebAssembly exports with multiple return values (e.g. `(result i32 i32)`)
produce a tuple TypeScript return type (`[number, number]`) instead of
collapsing to a single `number`.

Fixes #34065
@bartlomieju

Copy link
Copy Markdown
Member

@lunadogbot can you add a test for this wasm feature? Place it next to other wasm import tests

Adds tests/specs/check/wasm_multi_value/ which type-checks a TS
file importing a wasm function whose signature has multiple return
values. The wasm module exports `add_and_sub(i32, i32) -> (i32, i32)`;
the generated TypeScript declaration must use the tuple return type
`[number, number]` rather than collapsing to `number`.
@lunadogbot

Copy link
Copy Markdown
Contributor Author

Added a spec test in tests/specs/check/wasm_multi_value/. It type-checks a TS file that imports a wasm function with signature (i32, i32) -> (i32, i32) and assigns the result to string, asserting that the reported actual type is [number, number]. Without this PR's deno_graph bump the same test reports the type as number, so it would fail.

@bartlomieju
bartlomieju merged commit 4be991e into main May 15, 2026
136 checks passed
@bartlomieju
bartlomieju deleted the orch/issue-81 branch May 15, 2026 14:48
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…noland#34070)

Bumps `deno_graph` from `=0.108.1` to `=0.108.2`.

Without this fix, importing a WebAssembly function whose signature has
multiple return values (e.g. `(result i32 i32)`) generates a TypeScript
declaration whose return type collapses to a single `number` instead of the expected tuple
`[number, number]`, so `deno check` reports an incorrect type.

Reproduction from the upstream issue:

```sh
mkdir /tmp/wasm-multi-value && cd /tmp/wasm-multi-value
deno run --allow-read --allow-write --allow-env - <<'JS'
import wabtMod from "npm:wabt@1.0.36";
const wabt = await wabtMod();
const wat = `(module
  (func $add_and_sub (param $a i32) (param $b i32) (result i32 i32)
    local.get $a local.get $b i32.add
    local.get $a local.get $b i32.sub)
  (export "add_and_sub" (func $add_and_sub)))`;
const mod = wabt.parseWat("t.wat", wat, { multi_value: true });
await Deno.writeFile("test.wasm", mod.toBinary({}).buffer);
JS

cat > test.ts <<'TS'
import { add_and_sub } from "./test.wasm";
const r: "expected-tuple" = add_and_sub(1, 2);
TS

./target/debug/deno check test.ts
```

With this PR, the inferred return type is now `[number, number]` rather
than `number`.

Fixes denoland#34065
---------

Co-authored-by: lunadogbot <lunadogbot@users.noreply.github.com>
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.

The return value type of a function using Wasm Multi-Value becomes a number

2 participants