Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
JavaScript to TypeScript type/interface mapping

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.add is 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?

Response from connect

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The reason is, in the interface, OnvifDevice, add is a mandatory parameter, but the device object is initialised with an empty object.

The dynamic mapping at this.device = response is not happening. Also please check if the response has add method or not while you debug.

These are the two possible symptoms I see.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!