fix(napi-derive): should not generate this types for Constructor/Getter/Setter
This commit is contained in:
parent
7e3b1ef330
commit
32a039aad0
2 changed files with 21 additions and 13 deletions
|
@ -65,6 +65,7 @@ pub(crate) static PRIMITIVE_TYPES: &[(&str, &str)] = &[
|
||||||
("i16", "number"),
|
("i16", "number"),
|
||||||
("i32", "number"),
|
("i32", "number"),
|
||||||
("i64", "number"),
|
("i64", "number"),
|
||||||
|
("f32", "number"),
|
||||||
("f64", "number"),
|
("f64", "number"),
|
||||||
("u8", "number"),
|
("u8", "number"),
|
||||||
("u16", "number"),
|
("u16", "number"),
|
||||||
|
|
|
@ -139,24 +139,31 @@ impl NapiFn {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if let syn::Type::Path(path) = path.ty.as_ref() {
|
if let syn::Type::Path(path) = path.ty.as_ref() {
|
||||||
if let Some(PathSegment {
|
if let Some(PathSegment { ident, arguments }) = path.path.segments.last() {
|
||||||
ident,
|
|
||||||
arguments:
|
|
||||||
PathArguments::AngleBracketed(syn::AngleBracketedGenericArguments {
|
|
||||||
args: angle_bracketed_args,
|
|
||||||
..
|
|
||||||
}),
|
|
||||||
}) = path.path.segments.last()
|
|
||||||
{
|
|
||||||
if ident == "Reference" || ident == "WeakReference" {
|
if ident == "Reference" || ident == "WeakReference" {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if ident == "This" {
|
if ident == "This" || ident == "this" {
|
||||||
if let Some(syn::GenericArgument::Type(ty)) = angle_bracketed_args.first() {
|
if self.kind != FnKind::Normal {
|
||||||
let (ts_type, _) = ty_to_ts_type(ty, false, false);
|
return None;
|
||||||
|
}
|
||||||
|
if let PathArguments::AngleBracketed(syn::AngleBracketedGenericArguments {
|
||||||
|
args: angle_bracketed_args,
|
||||||
|
..
|
||||||
|
}) = arguments
|
||||||
|
{
|
||||||
|
if let Some(syn::GenericArgument::Type(ty)) = angle_bracketed_args.first() {
|
||||||
|
let (ts_type, _) = ty_to_ts_type(ty, false, false);
|
||||||
|
return Some(FnArg {
|
||||||
|
arg: "this".to_owned(),
|
||||||
|
ts_type,
|
||||||
|
is_optional: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
return Some(FnArg {
|
return Some(FnArg {
|
||||||
arg: "this".to_owned(),
|
arg: "this".to_owned(),
|
||||||
ts_type,
|
ts_type: "this".to_owned(),
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue