Twilio Video with Typescript

I have created a component with Angular 2 and Typescript that lets you create video calls using the Twilio Video library. I am trying to create a custom input for the Typescript library twilio-video, the way used in other posts like:

declare var Twilio:any;

      

only work for mine when i used twilio client library but not with twilio video.

interface Twilio {
  //Other declarations here
  Video: any;
}
declare namespace Twilio {
  //Others interface here like Connection and Device from client library
  interface Video {
    connect(token: string, options?:Object): Promise;
    createLocalTracks(options?:Object): Promise;
    //Other declarations of methods
  }
}

      

and finally can declare:

declare var Twilio:Twilio;

      

With this custom type, make a video call, I can create a room and create local tracks, but I cannot use the disabled or activated methods from LocalTrack, I go through the twilio-video library code and read about creating custom types and I think the library needs a template similar to show here , something like this:

export as namespace Twilio;
export = Video;

declare class Video {
  connect(token:string, options: Object): Promise;
  createLocalTracks(options?: Object): Promise;
  //Other declarations of functions of Video
}

declare namespace Video {
   export interface LocalVideoTrack {
       new(mediaStream:any, mediaStreamTrack:any, options:Object);
       disable():void;
       enable():void;
   }
}

      

This way can be used as a Twilio namespace, but cannot declare anything with Twilio.Video as the library being used, I cannot use instanceof to create var and have no relationship with the library code.

The main problem for me is that I cannot properly declare a custom Typescript set that used all the functions declared in the twilio video library. I recently used Typescript just a few weeks ago.

+3
angular typescript twilio typescript-typings


source to share


No one has answered this question yet

Check out similar questions:

1609
What is TypeScript and why would I use it instead of JavaScript?
664
TypeScript Convert string to number
539
get and install in TypeScript
222
Checking interface type with Typescript
1
How to add additional information to a Twilio connection object
0
Typcript, what's the best approach to declare a nested object with different types?
0
Extending external type declarations in Typcript
0
TypeScript error Cannot find name in 'SyncClient' Twilio
0
How do I add custom text to generate a D.TS file with the TypeScript compiler?
0
Is it possible to export namespaced / module encapsulated interfaces / types to TypeScript?



All Articles
Loading...
X
Show
Funny
Dev
Pics