Description
I'm building an application framework in javascript and just porting it over to typescript to use some of that sweet static typing. In my framework I happen to have a concept of a UI module. A UI module is a class and can be instantiated many times in an application. All modules have static definitions of their nature like what events they can trigger and what internal models they make publicly available. The implementation of these modules is a application-implementaional part on a level above the framework codebase, but the framework needs to treat the modules polymorphically (non-instantiated) to read these definitions to set up the application engine accordingly.
If there was the possibility to define static fields in an interface this would take care of making this contract explicit and statically validated for the application developer. But we don't have that. I'm sure that this contract could be enforced by wrapping the module classes in some kind of factory pattern or other contraptions, but I'm honestly not very attracted to that.
Wouldn't it be neat if we can enforce a static contract in typescript, considering the dynamic nature of the underlying javascript where this kind of static type polymorphism isn't all that weird?