rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript
https://rustwasm.github.io/docs/wasm-bindgen/
Apache License 2.0
7.84k stars 1.08k forks source link

Improved variable names in generated JS #4280

Open RunDevelopment opened 6 days ago

RunDevelopment commented 6 days ago

This PR implements a change I wanted to do for a while. The bindings defined JS variables inconsistently, using const, let, and var all over the place. As it turns out, most variables can be declared as const and everything else can be var. So I create a simple API for creating variables. This API also takes care of resolving naming conflicts, so we'll never have to worry about temporary variables conflicting with argument names ever again. In the future, this system may also be used to resolve other naming conflicts, but I kept it simple for now.

For those needing a refresher on var, let, and const in JS:

Changes:

RunDevelopment commented 6 days ago

Please merge #4281 before this PR, because it includes code gen for most of the binding instructions this PR changes.