[TS] Getting the `new` type from an interface
A 3rd party library I'm using specifies a generic interface for a static class.
On the interface is a key like
new <T = InterfaceT>(arg0: T): ComplexTypeExpr
.
I want to access that ComplexTypeExpr
as part of modifying the type of the constructor to new(arg0: InterfaceT): ComplexTypeExpr
Typically I would just rewrite the return type by importing the necessary types and building the expression. However, the expression uses generics which are on the interface which, unlike the one used in arg0
, I cannot access.
I also cannot simply extend the interface, as the interface is buried deep within several functions and types which I would also have to redeclare entirely, which would take up several hundred lines.
Is there some way I can index an interface to obtain the return type of the constructor?
I've tried things like typeof instaceOfInterface["new"]
, but nothing seems to work.
This is fairly important for type inference, as the library's default is "literally any data is valid" due to a lack of extends
in it's generic.0 Replies