From 8c281fd174b55f8393666621b41d5d252f7d689d Mon Sep 17 00:00:00 2001 From: forehalo Date: Fri, 24 Sep 2021 20:19:54 +0800 Subject: [PATCH] add static method example --- examples/napi/__test__/typegen.spec.ts.md | 1 + examples/napi/__test__/typegen.spec.ts.snap | Bin 658 -> 671 bytes examples/napi/index.d.ts | 1 + examples/napi/src/class.rs | 5 +++++ 4 files changed, 7 insertions(+) diff --git a/examples/napi/__test__/typegen.spec.ts.md b/examples/napi/__test__/typegen.spec.ts.md index 9cf5bdc4..b2dd10ea 100644 --- a/examples/napi/__test__/typegen.spec.ts.md +++ b/examples/napi/__test__/typegen.spec.ts.md @@ -33,6 +33,7 @@ Generated by [AVA](https://avajs.dev). get name(): string␊ set name(name: string)␊ whoami(): string␊ + static getDogKind(): Kind␊ }␊ export class PackageJson {␊ name: string␊ diff --git a/examples/napi/__test__/typegen.spec.ts.snap b/examples/napi/__test__/typegen.spec.ts.snap index bc94ec3ffba09ae847bfdf012e57fa607ea6d597..cf99096f64e34e188570c55b2513736814426132 100644 GIT binary patch literal 671 zcmV;Q0$}|?RzVEGZlz>naD zkhpW^FL30B#CVr&HeV{)!|t>F-kb4wybuIIE!g<@_{aBO@4tL{`t0}5Z(l#x0{=X` z9|Rl0gB;g3gGcxNY>LZ~HV%53;!bJ>ec|3|6I)Ub;m8w6{5=0 zNSH;U&C;BR>voQd+5#>rhp5L(ivA&mL&fb;5GWPzIbW1@>Qq|OS-__!KqX+TtiFu;Q+QN zG?_!tpwP``dT z{=i3gPT@@E+7~Dh%A0IYW8H4W2R+v(yE{aLv%yy%j~f_0$xBIARVZbn&d4J&W=UyO zmUnKvAZBq)SV^J~m2h=NJsD}mIG04-O-`hBo#^6JTv?){ixBW7xVy9GIUc(csPwxo zG>aUq9Fxiti$}vn*;o`D_L*?EEgV9mbt0Hr=D?ZjIz!UTbt{4btl+wL;Zg=zJ=4olNMOiPW)7e*wfTRbVUz F004NiL-YUu literal 658 zcmV;D0&V?4RzV>Kg{N&G%uU|e@0{{H3 z2Ek5nKgX47@ZjFhs<<9%>rhprb!ZYruEJ^+=z$^62`r?Jv%2%PZEa(DH2WL{nFol-x!x7Xe zG?_!tpwPiV{>$ERf+pnh3QDVlw7;8^QFfhW~_9>j|%piJ1p)0Qu98hS> z{=i3gO5t4Q+Gi*c$~&nqV$F}@gI?(8`+G!$%fYv|#|?}g=cOduDwMKeXXp_bv7~TR zly_ylCT4L=SV5u?6>xh-JsD}mIG04-PEMqCo#^sROf1pSWeE5Z+}%3!9NX>$D*dTv znsts=j!9*S#ny093>F24b0*w;ghPn5P6Sh%JaFc^&X6>7-I8Diw(#G$UgLn^4a-5d z(3DnNgfE$ss^OJ0)ZHA8C(K$nQ8Hx-Om`u_0$L>#xWWMs^D##&`b1sE9gfCggMwn| zycRX&VJUJOSp)*Gg>jWV9%z=z68B~~tg>o)*H5Gc7Oz0gGsbQJ^0>)3MgAfJ)0B_DY^Z)<= diff --git a/examples/napi/index.d.ts b/examples/napi/index.d.ts index e354a68c..655b8355 100644 --- a/examples/napi/index.d.ts +++ b/examples/napi/index.d.ts @@ -23,6 +23,7 @@ export class Animal { get name(): string set name(name: string) whoami(): string + static getDogKind(): Kind } export class PackageJson { name: string diff --git a/examples/napi/src/class.rs b/examples/napi/src/class.rs index 91c060ba..73321425 100644 --- a/examples/napi/src/class.rs +++ b/examples/napi/src/class.rs @@ -41,6 +41,11 @@ impl Animal { Kind::Duck => format!("Duck: {}", self.name), } } + + #[napi] + pub fn get_dog_kind() -> Kind { + Kind::Dog + } } #[napi(constructor)]