getGenericPasswordfalse
如果出错则返回,否则返回object
( credentials
)。我不确定这种联合类型是否可以合理地表示,但更好的 API 将是一个选项(选项(凭据))的结果。但是,我怎样才能在绑定文件中转换Promise<boolean | credentials>
-> 。Js.Promise.t(option(credentials))
下面是一个模板。
谢谢你的帮助。
[@bs.deriving abstract]
type credentials = {
service: string,
username: string,
password: string,
};
/* TODO convert the actual return value
Js.Promise.t(option(credentials)) to more reason type
Js.Promise.t(option(credentials)) */
[@bs.module "react-native-keychain"] [@bs.scope "default"]
external getGenericPassword: unit => Js.Promise.t(option(credentials)) = "";