-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Allow partial JSON for command callers but not receivers #34
Conversation
While this compiles, does this make sense? E.g. won't this allow errors to creep into the JS that were previously caught by the compiler? execute(args) {
for (let key in args) {
if (args[key] !== null) {
console.log(args[key].toString());
}
}
}
commands.execute('myid', { foo: undefined }); |
We could strip out all args that are |
I think that would defeat the purpose of accepting partial types 😄 |
I don't think so - we aren't claiming to use any |
Notes:
|
It turned out that |
After this is merged, I'll cut a patch of |
Ci failure seems relevant. |
I addressed it in the last commit, does that look good to you? |
What the heck, it is working for me locally... |
It fails for me locally. Maybe a |
7bfaad6
to
72aaec9
Compare
I couldn't find a way to allow |
@vidartf are we good to merge this? |
I've been going back and forth with myself whether I think this is a good idea. Adding a bunch of recursive copy operations just to satisfy backwards compatibility / typings seems like a bad trade to make. On the other hand, I don't want this to be left unresolved much longer. |
What if instead of |
That sounds scary. There's no limit on the depth of a json obj, so recursive anything could end up being arbitrarily expensive. Since this is part of Lumino, I think that in general we should favor performance over getting the typings perfect. As a pragmatic matter, how frequently are calls actually made to eg Also, would the |
It isn't just Another alternative is to expose just a |
Just for clarity and summary: The main point of this work is that previous to #32, command implementors could rely on that if a key was present in the args, then the corresponding value was not The other alternative is to revert #32, but add a utility method The last alternative is a more pragmatic "what is done is done", and just leave things as-is. Not sure about that one. |
It is likely to be a lot cheaper since it modifies in-place. I vote for this, given the alternatives. Then we can potentially relax this constraint for the next major version bump. |
Updated to add the |
Alternative to #33, addresses #32 (comment).
Allows invokers of commands to pass in
PartialReadonlyJSONObject
values, but ensures that the command consumers receiveReadonlyJSONObject
values (through API and by strippingundefined
values).