Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Typescript, create function returns wrong type #64

Open
thomaswp opened this issue Mar 10, 2024 · 0 comments
Open

In Typescript, create function returns wrong type #64

thomaswp opened this issue Mar 10, 2024 · 0 comments

Comments

@thomaswp
Copy link

In your type definitions, the ObservableSlim.create() function returns a type ProxyConstructor. I think this is incorrect. ProxyConstructor is just a type defined explicitly for the object Proxy, and all it can do is be constructed, i.e. new Proxy(...).

If I run:

let x = {} as MyState
let state = ObservableSlim.create(x, true, changes => {
    console.log('State changed', changes);
});
x.y = 3;

I would expect state to be of type MyState, or possibly object, but definitely not ProxyConsructor. I get an error on the last line, even if the type MyState has a property x. If you construct a Proxy, it will be of the same type as the first argument, so I think create should world the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant