Merge pull request #847 from napi-rs/mut-arg
fix(napi-derive-backend): typegen issue when arg is mut
This commit is contained in:
commit
4ff51a3c66
4 changed files with 8 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
use convert_case::{Case, Casing};
|
||||
use quote::ToTokens;
|
||||
use syn::Pat;
|
||||
|
||||
use super::{ty_to_ts_type, ToTypeDef, TypeDef};
|
||||
use crate::{CallbackArg, FnKind, NapiFn};
|
||||
|
@ -49,6 +50,11 @@ impl NapiFn {
|
|||
if path.ty.to_token_stream().to_string() == "Env" {
|
||||
return None;
|
||||
}
|
||||
let mut path = path.clone();
|
||||
// remove mutability from PatIdent
|
||||
if let Pat::Ident(i) = path.pat.as_mut() {
|
||||
i.mutability = None;
|
||||
}
|
||||
let mut arg = path.pat.to_token_stream().to_string().to_case(Case::Camel);
|
||||
arg.push_str(": ");
|
||||
arg.push_str(&ty_to_ts_type(&path.ty, false));
|
||||
|
|
|
@ -43,7 +43,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
export function readPackageJson(): PackageJson␊
|
||||
export function getPackageJsonName(packageJson: PackageJson): string␊
|
||||
export function contains(source: string, target: string): boolean␊
|
||||
export function concatStr(mutS: string): string␊
|
||||
export function concatStr(s: string): string␊
|
||||
export function concatUtf16(s: string): string␊
|
||||
export function concatLatin1(s: string): string␊
|
||||
export function withoutAbortController(a: number, b: number): Promise<number>␊
|
||||
|
|
Binary file not shown.
2
examples/napi/index.d.ts
vendored
2
examples/napi/index.d.ts
vendored
|
@ -33,7 +33,7 @@ interface PackageJson {
|
|||
export function readPackageJson(): PackageJson
|
||||
export function getPackageJsonName(packageJson: PackageJson): string
|
||||
export function contains(source: string, target: string): boolean
|
||||
export function concatStr(mutS: string): string
|
||||
export function concatStr(s: string): string
|
||||
export function concatUtf16(s: string): string
|
||||
export function concatLatin1(s: string): string
|
||||
export function withoutAbortController(a: number, b: number): Promise<number>
|
||||
|
|
Loading…
Reference in a new issue