2

Does a non-awkward way exist to specify a child class as argument type in a parent class method in TypeScript when the classes are defined in different files?

Comments
  • 4
    That kind of sounds like a poor design choice! Just saying! When it comes to OOP, parents typically should not know anything about their children. Maybe it would be better to do what you're trying to do in a separate class?
  • 0
    @Olverine
    Yep, it probably is a poor design choice - just looked like the least intrusive method to refactor some duplicated code into the super's method definition.
  • 4
    Definitely a bad design. Will create more issues than solving
  • 0
    I'm not sure I understand what you mean, but you can import types in a circular way without any issues most of the time. You can also use the type "this" to refer to the instance type, when you're returning the current instance for chaining.
Add Comment