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

Tell TypeScript API consumers when their objects are observable #483

Closed
spiffytech opened this issue Aug 12, 2016 · 1 comment
Closed

Tell TypeScript API consumers when their objects are observable #483

spiffytech opened this issue Aug 12, 2016 · 1 comment

Comments

@spiffytech
Copy link

Presently, calling mobx.observable({}) returns a T, and there's no way for my downstream code to assert that it's passed an observable object. Knowing when an object is observable is desirable for e.g., guaranteeing my React components receive objects that will actually mutate my UI when I change them.

My PR uses TypeScript 1.4's union types to change the return type of mobx.observable() to T & IObservable. This should be fully backwards-compatible, since TypeScript will still treat the object as type T. But now consumers have the option of enforcing that various pieces of their apps receive observable objects by demanding a mobx.IObservable.

@mweststrate
Copy link
Member

Merged PR, will be part of 2.5.2

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