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 a note about renaming types and js_class #1011

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions guide/src/reference/attributes/on-js-imports/js_name.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,18 @@ extern {

All of these functions will call `console.log` in JavaScript, but each
identifier will have only one signature in Rust.

Note that if you use `js_name` when importing a type you'll also need to use the
[`js_class` attribute][jsclass] when defining methods on the type:

```rust
#[wasm_bindgen]
extern {
#[wasm_bindgen(js_name = String)]
type JsString;
#[wasm_bindgen(method, getter, js_class = "String")]
pub fn length(this: &JsString) -> u32;
}
```

[jsclass]: js_class.html