From 881fd52063fe6766e221979ab2cad192402dd1fc Mon Sep 17 00:00:00 2001 From: Flux Xu Date: Sun, 2 Jan 2022 22:28:35 -0500 Subject: [PATCH] fix(napi-derive): unraw rust identifiers before sending it to js. (#987) --- crates/macro/src/parser/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/macro/src/parser/mod.rs b/crates/macro/src/parser/mod.rs index 91cb7ef7..23c9c7e1 100644 --- a/crates/macro/src/parser/mod.rs +++ b/crates/macro/src/parser/mod.rs @@ -15,6 +15,7 @@ use napi_derive_backend::{ }; use proc_macro2::{Ident, TokenStream, TokenTree}; use quote::ToTokens; +use syn::ext::IdentExt; use syn::parse::{Parse, ParseStream, Result as SynResult}; use syn::{Attribute, Signature, Type, Visibility}; @@ -745,7 +746,7 @@ impl ConvertToAST for syn::ItemStruct { let (js_name, name) = match &field.ident { Some(ident) => ( field_opts.js_name().map_or_else( - || ident.to_string().to_case(Case::Camel), + || ident.unraw().to_string().to_case(Case::Camel), |(js_name, _)| js_name.to_owned(), ), syn::Member::Named(ident.clone()),