Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow's Class<T> #47

Closed
levenleven opened this issue Jan 5, 2019 · 2 comments
Closed

Flow's Class<T> #47

levenleven opened this issue Jan 5, 2019 · 2 comments

Comments

@levenleven
Copy link
Contributor

Class<T>

Given a type T representing instances of a class C, the type Class is the type of the class C

Similar can be achieved in Typescript by typeof Foo but requires Foo to be a value, not a type. So can't be used with generics

Constructor part can be easily described by: type Constructor<T> = new (...args) => T;. This of course won't include any static members and won't verify inheritance (classes in Typescript not treated as nominal)

Maybe it is good enough to include only "constructor part"?

@piotrwitek
Copy link
Owner

I think what you proposed is good enough.

type Class<T> = new (...args) => T

It works correctly for all Flow use case examples (except nominal part but we don't care about it as TS is structural)

I accept PR

@levenleven
Copy link
Contributor Author

Great, I'll create a PR

piotrwitek pushed a commit that referenced this issue Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants