You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation (and functionally in practice), computed properties should be accessed as similarly to a getter when used outside of the template:
this.computedProperty.value
however typescript throws an error:
Property 'value' does not exist on type '() =>...
which looks like it's expecting computedProperty to be invoked:
this.computedProperty().value
it's more of an annoying type issue than anything else, everything seems to function as expected
The text was updated successfully, but these errors were encountered:
hello @anthony9187, computed props can be accessed outside the template scope by referring to them simply as this.mycomputedProperty. There is no .value-suffix involved there, so Typescript is correctly telling you that Property 'value' does not exists ...
There is also no need to invoke the computed property. The idea is that whenever you access the property (i.e. this.mycomputedProperty) the function associated with the property is executed, allowing you to dynamically generate the response value.
I've tried to search the docs, to see if it's documented wrongly somewhere, but couldn't find it. I may have missed something, so if you wouldn't mind please let us know where this was documented incorrectly (or confusing).
Hey @michielvandergeest, sorry if my example was unclear - .value was just an example. In this screenshot we can see what I mean:
I have a computed property getStyles that returns an object which has a property gutterX. If I attempt to reference the computed property as you've described, I'm met with the above error which incorrectly tells me I need to invoke the method.
According to the documentation (and functionally in practice), computed properties should be accessed as similarly to a getter when used outside of the template:
however typescript throws an error:
which looks like it's expecting
computedProperty
to be invoked:it's more of an annoying type issue than anything else, everything seems to function as expected
The text was updated successfully, but these errors were encountered: