Skip to main content

Class fields in depth

Emi generates fields into classes, but each field is getting setters and getters to ensure 100% type safety upon usage. We achive this by closing all options to modify the object directly, and setter functions which would strictly check the values being passed.

Field types are categorized into the following groups, despite their Emi types:

  • Strings (nullable?)
  • Numbers (nullable?)
  • Class instances (object, one, etc.) (always nullable)
  • Boolean (nullable?)
  • Array of instances (not nullable)
  • Array of primitives (not nullable)

In this document, we are going to discuss how such fields would become available in javascript counter part, and how codegen enforces the type-safety to a next level.