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
I'm curious to know if ES6 class methods and other callback functions are officially supported by the r() function, or if they only work by coincidence.
I'm asking because the ReactiveProxy<T> type isn't callable, which means you get warnings/errors when using TS, but not when using JS. It also appears to work fine, so I'm not sure if it is intended behavior or not.
Here's an example of what I mean with an ES6 class:
classFoo{publicmutateState(): void{// mutates internal class state here}}// ...constdata=r(newFoo())data.mutateState();// <-- This will get a Typescript warning/error
It yields the following warning/error:
Type 'ReactiveProxy<() => void>' has no call signatures.
The same thing happens if I pass a function definition into the r() function instead of a new class (i.e. r({greet: () => alert('hi')}))
Like I said, though, having it mutate its own data works as expected (and even causes re-renders when placed in a template) if I tell Typescript to ignore the issue.
If it's intended to work, then maybe the ReactiveProxy<T> type needs a way to be callable?
If passing mutators into the r() method isn't intended, it would be useful to have it added to the docs.
The text was updated successfully, but these errors were encountered:
I'm curious to know if ES6 class methods and other callback functions are officially supported by the
r()
function, or if they only work by coincidence.I'm asking because the
ReactiveProxy<T>
type isn't callable, which means you get warnings/errors when using TS, but not when using JS. It also appears to work fine, so I'm not sure if it is intended behavior or not.Here's an example of what I mean with an ES6 class:
It yields the following warning/error:
The same thing happens if I pass a function definition into the
r()
function instead of a new class (i.e.r({greet: () => alert('hi')})
)Like I said, though, having it mutate its own data works as expected (and even causes re-renders when placed in a template) if I tell Typescript to ignore the issue.
If it's intended to work, then maybe the
ReactiveProxy<T>
type needs a way to be callable?If passing mutators into the
r()
method isn't intended, it would be useful to have it added to the docs.The text was updated successfully, but these errors were encountered: