InversifyJS
InversifyJS copied to clipboard
Add a getConstructor internal function
We currently use the constructor property to access the constructor of an instance. Our use cases allow this operation to be performed, but I think it has some cons we often access the constructor property from any typed values. There is also a more standard way to access the constructor of an object:
function getConstructor<T>(value: T): typeof T {
return Object.getPrototypeOf(value).constructor;
}
which would (kind of) work with number values which has no constructor (even if Number constructor generates Number objects instead of number primitives I think we could deal with it)
A utility function would allow us to have an uniform and typed way to get the constructor of an instance