Simply omit the constructor if you have no need for it. In essence, it is redundant as JavaScript/TypeScript automatically handles it. For an extended class, not having a constructor is equivalent to having an empty one.
In cases where you do not define your own constructor, a default one will be provided for you. If your class is a subclass, the default constructor will invoke the parent constructor and pass any arguments along.
Therefore, constructors in derived classes should include a super call. However, it is not mandatory to create an empty constructor or simply use super
inside (for derived classes), unless you intend to alter its functionality or signature.
If you wish to retain the constructor despite it being considered "useless," you can disable the linter rule that flags it.
It's important to note:
A lint rule may highlight constructors that only modify visibility of a parent constructor. -- Refer to the TS Docs and ES Docs for more information on this.
In Angular, having a seemingly trivial constructor with a super call is essential for certain scenarios like Injectable and Constructor (derived classes). Failure to include this could result in the error message:
This constructor is not compatible with Angular Dependency Injection because its dependency at index 0 of the parameter list is invalid.
Hence, in such cases, the eslint rule must be turned off.