jamsinclair / jSquash

Browser & Web Worker focussed wasm bundles derived from the Squoosh App.
Apache License 2.0
222 stars 14 forks source link

Add type declarations for all wasm files? #49

Open Zerebokep opened 7 months ago

Zerebokep commented 7 months ago

title, https://github.com/jamsinclair/jSquash/blob/main/examples/cloudflare-worker-esm-format/src/index.js

Screenshot

PNG wasm seems to be fine.

jamsinclair commented 6 months ago

Thank you! I'll try dive in and fix these up when I can. PRs are also welcome 🙇

jamsinclair commented 5 months ago

Thanks for your patience. Is this affecting your usage of the modules at all?

Typing this becomes difficult as it needs to be typed for the consuming environment. There might need to be different types depending on how it's being consumed due to WebAssembly being a non-standard import. E.g. Cloudflare resolves the import directly to a WebAssembly Module but there might be other bundlers or tools where this is not the case.

I'll leave this as is for now as I don't think there's an easy work-around.

Zerebokep commented 5 months ago

Nope, I'll add // @ts-ignore for now.

dreitzner commented 2 months ago

This is already the case in squoosh. The types where added manually (or generated somehow)

Original commit: https://github.com/GoogleChromeLabs/squoosh/commit/273b4211c9f9a9fcd8c5186332b0fb521b963479

jamsinclair commented 2 months ago

Yes, it seems wasm-pack generates them. All Rust-based codecs should have those definitions such as:

The other codecs are generated via the Emscripten tool. Perhaps there might be a flag or tool that can be used to help generate that?

Contributions or suggestions are welcome 🙇