我想升级"paypal-rest-sdk" typings。此SDK包含方法Bitmap bitmap = BitmapFactory.decodeResource(mainImageUri);
;
payment.authorization.void(...)
上不存在 void
方法,我试图通过本地声明覆盖它。
代码示例:
@types/paypal-rest-sdk
但是这段代码不起作用,当我尝试调用declare module "paypal-rest-sdk" {
export namespace authorization {
function void(): any;
}
}
export const paypal = Paypal;
方法时,typescript会向我显示错误:void
答案 0 :(得分:1)
The only way I can see to provide a type definition that includes a method named void
(sigh) is using a variable rather than a namespace.
Here is an example based on the current definition on Definitely Typed (but with the authorization
namespace converted to a variable).
export var authorization: {
get: (
id: string,
config: http.RequestOptions | CallbackFunction<AuthorizationResource>,
cb?: CallbackFunction<AuthorizationResource>) => void;
capture: (
id: string,
data: CaptureRequest | http.RequestOptions | CallbackFunction<CaptureResource>,
config?: http.RequestOptions | CallbackFunction<CaptureResource>,
cb?: CallbackFunction<CaptureResource>) => void;
reauthorize: (
id: string, data: Amount | http.RequestOptions | CallbackFunction<AuthorizationResource>,
config?: http.RequestOptions | CallbackFunction<AuthorizationResource>,
cb?: CallbackFunction<AuthorizationResource>) => void;
void: (data?: any, config?: http.RequestOptions, cb?: CallbackFunction<any>) => void;
}
Specific changes:
export namespace authorization
changed to export var authorization
export function
converted to memberThis can be accessed without type errors:
...authorization.void(data, config, callback);