-
-
Notifications
You must be signed in to change notification settings - Fork 348
Add a keyof-based inject #615
Comments
if you want to prevent typos for inject just use string constants, like var USER_STORE = 'userStore' in some central location, no need for any increased complexity. plus the devtools will warn you immediately if you inject an unavailable store. |
I would say that is increasing complexity without any real benefit, afterall I already have the interface for the props. |
I dont see the point in adding an interface twice to the same component? |
Yes, it would be great if the inject would propagate the prop to the class, but I don't think you can do that with decorators in TS. |
I usually just do const {myKeys} = this.props.userStore as UserStore |
Closing for inactivity. See also #256 |
Hi, would it be possible to improve TS bindings for inject, where it wouldn't use simple strings, but template param based keyof instead?
We already have helper interfaces, so it would be nice if these could be passed to inject:
I had a look in mobx sources, and they mentioned some TS decorator bugs, so perhaps this isn't possible atm? But if it is, it would prevent typos when using inject, and provide a tiny bit more type-safety. (of course the string[] based inject could be kept when not using any template params)
The text was updated successfully, but these errors were encountered: