DEV Community

Discussion on: Simple trick to instance a class without `new`.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀 • Edited

To keep typings do this (@ts-ingore is required but everything still works):


type ConstructedClass = (...args: any[]) => GLRConstructor;
// @ts-ignore
export const callableObject: typeof Dog & ConstructedClass = Reflect.construct.bind(
  null,
  Dog
);