Skip to content

Classes and Interfaces

In Targo, class is best understood as a Go-first structure-and-methods tool, not a JavaScript inheritance system.

Core ideas

  • class is close to a Go struct with reference semantics
  • interface is a Go-style behavior contract
  • composition is preferred over inheritance
  • constructor is supported, but that does not make Targo a JS class runtime

Practical advice

  • use class for domain structures and stateful behavior
  • use interface for boundaries and substitution
  • use #field for private fields
  • use composition or embedding instead of trying to recreate extends