diff --git a/crates/backend/src/lib.rs b/crates/backend/src/lib.rs index 9ea18085..3ba74cd8 100644 --- a/crates/backend/src/lib.rs +++ b/crates/backend/src/lib.rs @@ -65,6 +65,7 @@ pub(crate) static PRIMITIVE_TYPES: &[(&str, &str)] = &[ ("i16", "number"), ("i32", "number"), ("i64", "number"), + ("f32", "number"), ("f64", "number"), ("u8", "number"), ("u16", "number"), diff --git a/crates/backend/src/typegen/fn.rs b/crates/backend/src/typegen/fn.rs index b6ae0fd0..be135729 100644 --- a/crates/backend/src/typegen/fn.rs +++ b/crates/backend/src/typegen/fn.rs @@ -139,24 +139,31 @@ impl NapiFn { return None; } if let syn::Type::Path(path) = path.ty.as_ref() { - if let Some(PathSegment { - ident, - arguments: - PathArguments::AngleBracketed(syn::AngleBracketedGenericArguments { - args: angle_bracketed_args, - .. - }), - }) = path.path.segments.last() - { + if let Some(PathSegment { ident, arguments }) = path.path.segments.last() { if ident == "Reference" || ident == "WeakReference" { return None; } - if ident == "This" { - if let Some(syn::GenericArgument::Type(ty)) = angle_bracketed_args.first() { - let (ts_type, _) = ty_to_ts_type(ty, false, false); + if ident == "This" || ident == "this" { + if self.kind != FnKind::Normal { + 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 { arg: "this".to_owned(), - ts_type, + ts_type: "this".to_owned(), is_optional: false, }); }