-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(iOS): preserve null values in bridged types #4072
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would adding a test for [JSValue?] and heterogeneous arrays make sense (in BridgedTypesTests.swift
)?
More tests are good, but I'm not clear on what use-case you're suggesting covering? |
@ikeith Does something like this make sense? let array: [Any] = ["test string 1", 1, NSNull()]
let sparseArray = JSTypes.coerceArrayToJSArray(array)?.capacitor.replacingNullValues() as? [JSValue?]
// sparseArray should cast successfully and not be nil |
@dwieeb That kind of test was already added to the test suite: |
This branch extends JSValue to include NSNull in order to preserve null values sent from JS. It also adds some small extensions to Array to improve the ergonomics when working in Swift, and adds unit tests to document and verify the behavior.
This branch also deprecates
hasOption
onCAPPluginCall
as the presence of a key in the options isn't significant and we shouldn't encourage that pattern. Typing the represented value if it is not nil is more meaningful.This addresses the underlying cause that #4048 worked around.