Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for symbols in js_name and getter/setter #4230

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RunDevelopment
Copy link
Contributor

@RunDevelopment RunDevelopment commented Oct 28, 2024

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 Fixed imports with late binding and this #4225, Fixed generated types for getters and setters #4202, and Add null to argument types of optional parameters #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 Fixed imports with late binding and this #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 Generate Symbol.dispose on classes #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.

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.

Support symbols for fields and functions of exported structs
1 participant