mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-14 05:21:24 +00:00
Use the JS name of an imported type for instanceof
checks
This commit is contained in:
@ -542,6 +542,9 @@ impl ConvertToAst<BindgenAttrs> for syn::ForeignItemType {
|
||||
type Target = ast::ImportKind;
|
||||
|
||||
fn convert(self, attrs: BindgenAttrs) -> Result<Self::Target, Diagnostic> {
|
||||
let js_name = attrs
|
||||
.js_name()
|
||||
.map_or_else(|| self.ident.to_string(), |s| s.to_string());
|
||||
let shim = format!("__wbg_instanceof_{}_{}", self.ident, ShortHash(&self.ident));
|
||||
Ok(ast::ImportKind::Type(ast::ImportType {
|
||||
vis: self.vis,
|
||||
@ -549,6 +552,7 @@ impl ConvertToAst<BindgenAttrs> for syn::ForeignItemType {
|
||||
doc_comment: None,
|
||||
instanceof_shim: shim,
|
||||
rust_name: self.ident,
|
||||
js_name,
|
||||
extends: attrs.extends().cloned().collect(),
|
||||
}))
|
||||
}
|
||||
|
Reference in New Issue
Block a user