8000 In Typescript, create function returns wrong type · Issue #64 · ElliotNB/observable-slim · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
In Typescript, create function returns wrong type #64
Open
@thomaswp

Description

@thomaswp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0