-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Getters/Setters for fields #1440
Conversation
Is it possible to eliminate the extra method on the JS side and keep only the getter? |
@RReverser Sure. I was a bit apprehensive about this aspect but I finally came up with the following rules.
¹ Duplicated getters or duplicated setters |
Ah, so this extra method is generated only due to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay in review, I didn't realize this was ready! Feel free to ping whenever it's ready and we can take a look
crates/cli-support/src/js/mod.rs
Outdated
method(class, &docs, getter_name, "set ", &js, &ts); | ||
} | ||
} | ||
_ => method(class, &docs, fn_name, static_prfx, &js, &ts), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this return an error for unsupported OperationKind
types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should an error be thrown? This line code roughly translates to: Don't do fancy things for anything that isn't a getter or a setter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah I think we should generate an error here because something like #[wasm_bindgen(indexing_getter)]
(or something like that) isn't fully supported here
guide/src/reference/attributes/on-js-imports/getter-and-setter.md
Outdated
Show resolved
Hide resolved
Thanks again for this @c410-f3r! |
Fixes #222.