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

Type definitions could be cleaner if the Blot and BlotConstructor interface were removed #53

Closed
charrondev opened this issue Apr 8, 2018 · 4 comments

Comments

@charrondev
Copy link
Contributor

I've been trying to improve the type definitions for Quill and have been running into this issue lately. There are quite a few places where something is typed as being Blot (from the interface) or BlotConstructor (an interface with new(): Blot). The largest issue with the Blot/BlotConstructor interface is that it requires defining static and instance properties/methods in different places. Instead you should be able to use the base Blot class ShadowBlot as a class, and where you need its constructor use typeof ShadowBlot.

@jhchen
Copy link
Member

jhchen commented Apr 9, 2018

I believe typeof ShadowBlot will return 'function', which is not the same.

@charrondev
Copy link
Contributor Author

So typeof ShadowBlot is essentially the constructor function, but it will also have any statically declared properties present. If you take a look at the PR I submitted you'll see that it ends up working quite well.

If you look through the Advanced section of the typescript handbook classes can be used as interfaces. typeof SomeClass is also an interface with a new(): SomeClass declaration and all static properties of the class.

@jhchen
Copy link
Member

jhchen commented Apr 17, 2018

The current implementation follows the example in https://www.typescriptlang.org/docs/handbook/interfaces.html#difference-between-the-static-and-instance-sides-of-classes. You are right typeof ShadowBlot does more than the Javascript typeof so I'll take a look at removing BlotConstructor.

@quill-bot
Copy link

Closing inactive issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants