add static method example

This commit is contained in:
forehalo 2021-09-24 20:19:54 +08:00 committed by LongYinan
parent f4c0b0639b
commit 8c281fd174
4 changed files with 7 additions and 0 deletions

View file

@ -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␊

View file

@ -23,6 +23,7 @@ export class Animal {
get name(): string
set name(name: string)
whoami(): string
static getDogKind(): Kind
}
export class PackageJson {
name: string

View file

@ -41,6 +41,11 @@ impl Animal {
Kind::Duck => format!("Duck: {}", self.name),
}
}
#[napi]
pub fn get_dog_kind() -> Kind {
Kind::Dog
}
}
#[napi(constructor)]