An interface is an agreement between the type and consumers of the type. If you are trying to ensure that the class can be instantiated without any arguments by consuming code, you're already done. Whether or you declare a zero-parameter constructor, consumers of the type can instantiate it without any arguments.
If on the other hand you're trying to use the type system to ensure that a zero-parameter constructor is defined that does something, that is not really a task static type checking is well suited for. Maybe look at verifying this in your unit tests.
In other words, this:
class Foo implements IConstructor {
}
Is not meaningfully different from this:
class Foo implements IConstructor {
constructor() {}
}
The only difference that matters:
class Foo implements IConstructor {
constructor() {
// ...
/* Is this */
// ...
}
}
And verifying the behavior of that part is better suited to unit tests than the type checker.
componentDldMount(see the misspell?) will fail silently, leaving you to track down the hideous bug yourself (not mentioning that you need to type the method name yourself all the time). This is why I generally dismiss APIs that provide hooks by exact method name matching. What you could do here is create a snippet in your IDE that creates the constructor method on, say, writingctor. - John Weiszclass Foo implements OnInit. I guess, a similar thing can be done with Flow. - Estus Flaskconstructoris an optional native hook method. A decorator-based approach is, IMO, much better, although decorators cannot be used with constructors, unfortunately. You cannot misspell, say,@componentDidMount, because it is detected by the TypeScript compiler. - John Weisz