Reputation: 367
The following class definition file: https://github.com/Bitcoin-com/bitbox-javascript-sdk/blob/master/lib/HDNode.d.ts
is missing the createAccount()
method here:
https://github.com/Bitcoin-com/bitbox-javascript-sdk/blob/master/lib/HDNode.js#L144
I am attempting to use the createAccount()
method and the typescript compiler is giving me an error. I'd like to be able to move past this error while keeping the rest of the class definition. How can I do that?
Thanks in advance.
Upvotes: 1
Views: 606
Reputation: 30879
The general idea would be to use a module augmentation, which would look something like this:
declare module "bitbox-javascript-sdk/lib/HDNode" {
interface HDNode {
createAccount(hdNodes: any): any;
}
}
(To make this a module augmentation rather than a module declaration, it needs to be inside another module, i.e., either put it in a file that has top-level imports or exports or wrap it in declare module "dummy" { }
.)
I'm unsure of the correct parameter and return types, but if you know the correct code pattern to use createAccount
, declaring the parameter and return types as any
will at least get you unblocked. (I think the existing method declarations are wrong. Many of them come in pairs with and without an argument of type HDNode
, but looking at the source, it appears that that argument is always required and its actual type is not the HDNode
class of bitbox-javascript-sdk
but what is referred to as _bitcoincashjsLib2.default.HDNode
in the JavaScript code.)
Upvotes: 4