wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

Add support for symbols in `js_name` and `getter`/`setter`

Open RunDevelopment opened this issue 1 year ago • 1 comments

Fixes #4149.

This PR adds basic support for js_name = Symbol.<name>. It generally works, but still needs to be polished.

TODO list:

  1. Resolve conflicts. This PR conflicts with #4225, #4202, and #4188. Those PR should be dealt with before this one.
  2. Fix the bug that getter = name doesn't rename imported static getters. See import_static_symbol_getter in crates/cli/tests/reference/symbol.rs. This might be fixed by #4225.
  3. Add a symbol name filter. Right now, any name is allowed, but we should only allow known symbol names. This should also blacklist Symbol.dispose as pointed out here.
  4. Automatically polyfill missing symbols. Just like #4118, we should polyfill symbols that aren't defined by the JS runtime. We could probably just generalize the expose_symbol_dispose method to do this.
  5. More testing, especially for the errors users get when using js_name = Symbol.name in invalid positions. Users should ideally get an error from the #[wasm_bindgen] macro, so users get errors in the IDEs.

RunDevelopment avatar Oct 28 '24 13:10 RunDevelopment

This would be extremely useful for a lot of things, I hope the maintainers take another look at this soon

sonthonaxrk avatar Sep 12 '25 13:09 sonthonaxrk