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.
source to share
No one has answered this question yet
Check out similar questions: