Skip to content

2.0.0-next.20

Pre-release
Pre-release

Choose a tag to compare

@3m1n3nc3 3m1n3nc3 released this 09 Apr 13:50

What’s Changed

Typed getAttribute() / setAttribute() inference

  • Improved getAttribute() so it now infers the return type from declared model properties, not just schema/generic attributes.
  • Improved setAttribute() so writes against declared model properties are type-checked consistently with getAttribute() reads.

Declared property support

  • Models with explicit declarations like declare name: string now get strongly typed attribute access:
    • user.getAttribute('name') resolves to string
    • user.setAttribute('name', value) enforces string

Relationship-aware attribute access

  • Extended attribute typing to relationship method keys when the relationship has been loaded onto the model.
  • getAttribute() now resolves the expected relationship payload type from the relationship method’s getResults() contract:
    • single-result relations resolve to RelatedModel | null
    • multi-result relations resolve to ArkormCollection<RelatedModel>
  • setAttribute() mirrors that behavior for assigning eager-loaded relationship payloads.

Type utilities

  • Added internal model relationship typing helpers to derive:
    • which model method names represent relationships
    • what resolved payload type each relationship exposes

Test coverage

  • Added type-level regression coverage for:
    • generic attribute inference
    • declared property inference
    • relationship payload inference for hasOne and hasMany
    • typed setAttribute() parity with getAttribute()

Developer Impact

  • Better IDE autocomplete and stronger compile-time guarantees when reading or assigning model attributes.
  • Less need for manual casts around eager-loaded relationships and declared model fields.

Full Changelog: 2.0.0-next.17...2.0.0-next.20