-
Notifications
You must be signed in to change notification settings - Fork 142
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
Make meta
optional
#53
Conversation
Otherwise we have to add `meta: null` to every action
Thanks for the patch! For some reason, I'm not seeing good errors on travis, but I tried the test command locally and it printed:
cc @unional |
Oh whoops, that's laziness on my part, I'll fix that! |
I'm not sure if this is the right change. If you define a If it is optional, then may be one option is to specify it as |
Good point! I find that I don't really use If I could do Also, I could just make my own |
That will be possible when generic default lands. In the mean time, I don't think overloading would work, but can give it a try |
Great, thanks for the feedback @unional. Up to you guys! |
You are welcome. It is a touchy point in TypeScript. The current typing is more strict and the good thing about it is that when generic default and Here are references to the issues if you are interested: |
@wub @unional thanks for the discussion, it's been informative to me too. Unless I'm misunderstanding something it seems like this is blocked by those Typescript issues? Specifically though, this point makes the most sense to me:
I would motion to close this PR in the meanwhile, possibly in favour of another one that "loosens" up the typings... though I'm not sure about what that looks like. TBPH I'm pretty happy with the way things are for now, but if others feel strongly that this needs to change somehow then I'm open to changes. :) |
FYI generic default is available in ts@next. XD |
@JaKXz Cheers! See you on the other side of ts@next ;) |
In the JSDocs, and README, it's still listed as optional (so is /**
* The optional `meta` property MAY be any type of value.
* It is intended for any extra information that is not part of the payload.
*/
meta: Meta; Shouldn't it be the same as |
will this be resolved? |
Do you mean fixing the readme? |
I mean when the PR will be actually merged or there will be done anything to mark |
As discusses above, keeping |
Oh, cool! Thanks for the explanation, it was not clear from the above comments that |
Yeah, sorry, @zowers (and anyone else), my PR is incorrect and will cause issues! I'll edit the parent. |
I thought we can set something like this?
|
@leesiongchan The first conversation happened before TypeScript 2.3, which introduced defaults for generics (like your example). But yes, we can do that now! I'll submit a request. |
See #94 |
While technically meta can be undefined when not used (to save space). Making it optional means every time you use it you need to check if it is undefined. And since you use it, you assume that your specific action will have meta defined. The same argument as redux-utilities/flux-standard-action#53
While technically meta can be undefined when not used (to save space). Making it optional means every time you use it you need to check if it is undefined. And since you use it, you assume that your specific action will have meta defined. The same argument as redux-utilities/flux-standard-action#53
(Edited) Don't use this PR; it'll cause issues, and better things on the way from the TS team.