Computed Properties
There are two variants of Ember’s computed properties you may encounter:
the decorator form used with native (ES6) classes
the callback form used with classic classes (based on EmberObject)
Decorator form
Note that it is impossible for @computed
to know whether the keys you pass to it are allowed or not. Migrating to Octane eliminates this issue, since you mark reactive root state with @tracked
and leave getters undecorated, rather than vice versa.
Callback form
Computed properties in the classic object model take a callback instead:
This definition will not type-check, however. You will need to explicitly write out a this
type for computed property callbacks for get
and set
to type-check correctly:
Note that this does not always work: you may get warnings from TypeScript about the item being defined in terms of itself.
Accordingly, we strongly recommend migrating classic classes to ES native classes before adding TypeScript!
Last updated
Was this helpful?