-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Change interface to class in exported types #2157
Conversation
Can someone help to review this? |
It seems OK to me, as those types are classes. |
Ah, you're right. For the style change, it's auto formatted by my IDE. I noticed that and didn't revert that because I saw editorconfig and prettier configured in the project. The formatting just follows those configs. |
And I think we'd better have style check in CI for better collaboration. But that's out of scope for this PR. |
Out in 3.8.1. |
Class constructor should be exported as class instead of interface.
Why does this matter? Interface is removed in runtime after compilation. But actually, types like
Logger
is accessible in pure js. For my use case, I'll need a runtime type as a dependency injection token, as well as a well-typed interface.Another reason is class is inheritable, but if one wants to make a class extending interface, he/she should implement all the methods declared in interface.
Ref: https://stackoverflow.com/questions/14345485/whats-the-difference-between-declare-class-and-interface-in-typescript