#How to get a constructor from a class?
8 messages · Page 1 of 1 (latest)
Preview:```ts
/**
- A utility type to get the constructor of the corresponding class.
*/
type Constructor<T> = "what do I put here?"
class Foo {
someValue = 123
}
type FooConstructor = Constructor<Foo>```
You can choose specific lines to embed by selecting them before copying the link.
From the class instance, not generally possible unless you add a property to the class that can be used to reference it... TS doesn't type Foo.constructor as typeof Foo