fix(napi-derive): unraw rust identifiers before sending it to js. (#987)
This commit is contained in:
parent
ca3790bdf1
commit
881fd52063
1 changed files with 2 additions and 1 deletions
|
@ -15,6 +15,7 @@ use napi_derive_backend::{
|
||||||
};
|
};
|
||||||
use proc_macro2::{Ident, TokenStream, TokenTree};
|
use proc_macro2::{Ident, TokenStream, TokenTree};
|
||||||
use quote::ToTokens;
|
use quote::ToTokens;
|
||||||
|
use syn::ext::IdentExt;
|
||||||
use syn::parse::{Parse, ParseStream, Result as SynResult};
|
use syn::parse::{Parse, ParseStream, Result as SynResult};
|
||||||
use syn::{Attribute, Signature, Type, Visibility};
|
use syn::{Attribute, Signature, Type, Visibility};
|
||||||
|
|
||||||
|
@ -745,7 +746,7 @@ impl ConvertToAST for syn::ItemStruct {
|
||||||
let (js_name, name) = match &field.ident {
|
let (js_name, name) = match &field.ident {
|
||||||
Some(ident) => (
|
Some(ident) => (
|
||||||
field_opts.js_name().map_or_else(
|
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(),
|
|(js_name, _)| js_name.to_owned(),
|
||||||
),
|
),
|
||||||
syn::Member::Named(ident.clone()),
|
syn::Member::Named(ident.clone()),
|
||||||
|
|
Loading…
Reference in a new issue