I'm using this library in a TypeScript project. And this is how my class looks like:
import OnvifManager from 'onvif-nvt'
Class OnvifApi {
// device: any = undefined
device = {} as OnvifDevice
constructor (...params) {
// definition
}
connect (): Promise<any> {
OnvifManager.connect(...params).then((response: OnvifDevice) => {
this.device = response
resolve(response)
}
}
coreService(): Promise<Type[]> {
this.device.add('core')
}
}
And this this interface I created for the response from onvif-nvt
interface OnvifDevice {
address: string
// type
// type
// type
add(name: string): void
}
This class is always giving an error in coreService saying that
this.device.addis not a function.
EDIT: This is the return of the connect method, which returns the whole Camera object.
Things are working when device is defined to any.
How can I do this interface mapping from JavaScript to TypeScript?

connectis giving you an object with anaddfunction? That runtime error would seem to indicate otherwise. Have you debugged to check what theresponseobject is?coreServiceis not called beforeconnectresolves?deviceis of typeany.device: OnvifDevice = {}instead ofdevice = OnvifDevice = {}? Or what are you trying to do here? And why isClassuppercase?