I'm writing TypeScript definitions file for a third-party library that exposes a global constructor function.
How do I write a class type which instance will be of a specific type?
declare class PexRTC {
// this doesn't work, returned instance is PexRTC, not PexRTC.PexipInstance
new(): PexRTC.PexipInstance;
}
declare namespace PexRTC {
export interface PexipInstance {
foo: true;
}
}
// How to make instance be PexRTC.PexipInstance ?
const instance = new PexRTC();