Skip to content

fix(npm): curate TypeScript declarations with Wasm parity - #110

Closed
google-labs-stitch[bot] wants to merge 1 commit into
mainfrom
stitch/curated-ts-declarations-wasm-parity-jm1-8c124ae9-d839-483b-a57a-e8b52378a352
Closed

google-labs-stitch[bot] wants to merge 1 commit into
mainfrom
stitch/curated-ts-declarations-wasm-parity-jm1-8c124ae9-d839-483b-a57a-e8b52378a352

Conversation

@google-labs-stitch

Copy link
Copy Markdown
Contributor

Summary

This pull request decouples the public TypeScript declarations of tunelet and tunelet/wasm from pkg/tunelet.d.ts, fixes { voices: undefined } deserialization in Wasm, adds .wasm subpath exports, and enables "file:" URL string support in Node.js.

Changes

  • Add portable structural TypeScript declarations in src/types.ts and a tunelet/wasm facade in src/wasm.ts with no references to ../pkg/tunelet.js, Symbol.dispose, RequestInfo, BufferSource, WebAssembly or __wbg_* fields.
  • Enable exactOptionalPropertyTypes and include src/types.ts and src/wasm.ts in tsconfig.json.
  • Decode undefined HarmonyConfig.voices to 4 in src/harmony.rs under the wasm target and declare voices?: number | undefined in tsify and src/types.ts while native pub voices: u8 stays unchanged.
  • Route "./wasm" to ./dist/wasm.d.ts and ./dist/wasm.js, and export "./pkg/tunelet_bg.wasm" and "./tunelet_bg.wasm" in package.json.
  • Update initialize in src/index.ts and README.md to read "file:" URL strings and cross-realm file: URL objects from disk in Node.js.
  • Expand scripts/verify-pack.mjs to check the twelve archive paths, declaration portability, bidirectional parity between src/types.ts and pkg/tunelet.d.ts, runtime { voices: undefined } and "file:" URL behavior, esbuild .wasm subpath resolution, and four tsc --strict --exactOptionalPropertyTypes consumer profiles (node, es2023, dom, webworker).

Verification

  • cargo fmt --check
  • cargo clippy --locked --lib -- -D warnings
  • cargo build --locked --release
  • RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps
  • cargo package --list --locked
  • npm ci
  • RUSTDOCFLAGS="-D warnings" npm run check:wasm
  • npm run verify:pack

Automated PR initiated by user @byteland-app via Stitch Loop.

- Add portable TypeScript facades in src/types.ts and src/wasm.ts
- Decode undefined HarmonyConfig.voices to 4 in the Wasm bindings
- Route ./wasm through ./dist/wasm.js and ./dist/wasm.d.ts
- Export ./pkg/tunelet_bg.wasm and ./tunelet_bg.wasm in package.json
- Read file: URL strings and cross-realm URLs in loadTunelet
- Verify type parity, strict tsc profiles and esbuild in verify:pack
@byteland-app

Copy link
Copy Markdown
Contributor

Closing as superseded by #123. Hand-maintaining a 573-line src/types.ts duplicates Rust types/rustdoc (against AGENTS.md single-source-of-truth guidance), adds esbuild + 26 platform packages to package-lock.json, and omits WebAssembly.Memory methods required by TS 7.0.

@byteland-app
byteland-app deleted the stitch/curated-ts-declarations-wasm-parity-jm1-8c124ae9-d839-483b-a57a-e8b52378a352 branch November 25, 2026 08:04
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Understood — leaving #110 closed with no further commits pushed to this branch, deferring to #123 so tsify and Rust rustdoc remain the single source of truth without duplicating declarations in src/types.ts, package-lock.json stays free of esbuild platform packages, and WasmMemory retains full TypeScript 7.0 WebAssembly.Memory method parity (grow, toFixedLengthBuffer, and toResizableBuffer).

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.

1 participant