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

Mobx flow type hinting using observable function around a map creates incorrect type #2355

Closed
paul23-git opened this issue May 12, 2020 · 3 comments

Comments

@paul23-git
Copy link

Intended outcome:

When creating a new map and making it observable using the function, the returned type is of a map without specifying the key type, or

Actual outcome:
The type of the key is "lost", and the type of the value is converted to V|undefined. - Or when not giving an initial value to the map the type of the value is just V

How to reproduce the issue:

The following line to a store, or anywhere (ps: how can I create a flow test on codesandbox?):
const someMap: ObservableMap<number, string> = observable(new Map());

Some extra discovery:

This seems to be due line 254 of mobx.js.flow:

export interface IObservableFactory {
    // observable overloads
    (target: Object, key: string, baseDescriptor?: PropertyDescriptor<*>): any;
    <T>(value: Array<T>): IObservableArray<T>;
    <T>(value: null | void): IObservableValue<T>;
    (value: null | void): IObservableValue<any>;
    <T>(value: IMap<string | number | boolean, T>): ObservableMap<T>;
    <T: Object>(value: T): T;
}

Versions
mobx: 5.15.3
flow: 0.124

@danielkcz
Copy link
Contributor

Can you please set up a simple reproduction with a Flow playground?

@mweststrate
Copy link
Member

mweststrate commented May 13, 2020 via email

@danielkcz
Copy link
Contributor

Closing for inactivity.

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

No branches or pull requests

3 participants