Open themaxdavitt opened 4 years ago
Oh interesting, thanks for the report! This is probably an issue where we shouldn't be using the input getter
identifier for a Rust identifier. We should probably be using something internal to wasm-bindgen itself. Should be a relatively simple change to the macro code generation to fix this!
Hey, I know I'm bumping an old issue, but I was curious about this again and just confirmed that this still happens. I still get a complaint about needing an identifier for the getter, and here's the full backtrace and isolated code for that panic from the function name.
Summary
I'm pretty new to the rust-wasm ecosystem but it doesn't seem obvious how to have fields that aren't normal rust identifiers.
Additional Details
I'm trying to export a rust type that's roughly equivalent to this typescript type:
I initially was going to create it like this:
But this approach doesn't work for two different reasons:
"@type"
as a valid rust identifiergetter = ...
to use an identifier, I getthread 'rustc' panicked at '"__wasm_bindgen_generated_GraphItem_r#type" is not a valid identifier', src\librustc_expand\proc_macro_server.rs:329:13
Obviously I can change the function name to something other than
r#type
to solve the second issue, but what should I do about wanting a@type
field?