wasm-bindgen
wasm-bindgen copied to clipboard
Add support for symbols in `js_name` and `getter`/`setter`
Fixes #4149.
This PR adds basic support for js_name = Symbol.<name>. It generally works, but still needs to be polished.
TODO list:
- Resolve conflicts. This PR conflicts with #4225, #4202, and #4188. Those PR should be dealt with before this one.
- Fix the bug that
getter = namedoesn't rename imported static getters. Seeimport_static_symbol_getterincrates/cli/tests/reference/symbol.rs. This might be fixed by #4225. - Add a symbol name filter. Right now, any name is allowed, but we should only allow known symbol names. This should also blacklist
Symbol.disposeas pointed out here. - 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_disposemethod to do this. - More testing, especially for the errors users get when using
js_name = Symbol.namein invalid positions. Users should ideally get an error from the#[wasm_bindgen]macro, so users get errors in the IDEs.
This would be extremely useful for a lot of things, I hope the maintainers take another look at this soon