Conversation
…sults (#42641) # Why When returning arrays/dictionaries to JS, their dynamic types only shallow-convert arguments, which breaks for more complex returned types. - When an array of mixed values is returned, the [`elementType`](https://github.com/expo/expo/blob/bf5c4aefbf6b67f37f5f6870a6f80c2efa4c8171/packages/expo-modules-core/ios/Core/DynamicTypes/DynamicArrayType.swift#L41) is of type [`DynamicRawType`](https://github.com/expo/expo/blob/main/packages/expo-modules-core/ios/Core/DynamicTypes/DynamicRawType.swift) even if array elements have their own dynamic type converters - The [`DynamicDictionaryType`](https://github.com/expo/expo/blob/main/packages/expo-modules-core/ios/Core/DynamicTypes/DynamicDictionaryType.swift) is missing the `convertResults` at all Example where this matters: [This return](https://github.com/expo/expo/blob/bf5c4aefbf6b67f37f5f6870a6f80c2efa4c8171/packages/expo-sqlite/ios/SQLiteModule.swift#L419) can be of type: ```js { lastInsertRowId: 1, changes: 0, firstRowValues: [1, <<ArrayBuffer>>] } ``` Primitives and nested arrays are converted, but ArrayBuffer is being `undefined` because, without this change, the `value` inside [`convertObjCObjectToJSIValue`](https://github.com/expo/expo/blob/bf5c4aefbf6b67f37f5f6870a6f80c2efa4c8171/packages/expo-modules-core/ios/JSI/EXJSIConversions.mm#L100) is of type [`ExpoModulesCore.NativeArrayBuffer`](https://github.com/expo/expo/blob/7cac70926cb456f8a1a7673d68d4a84800099071/packages/expo-modules-core/ios/Core/ArrayBuffers/ArrayBuffer.swift#L7) instead of `EXArrayBuffer` and the conditional is skipped. This is caused by [`DynamicArrayBufferType.convertResult()`](https://github.com/expo/expo/blob/7cac70926cb456f8a1a7673d68d4a84800099071/packages/expo-modules-core/ios/Core/DynamicTypes/DynamicArrayBufferType.swift#L35) not being called when converting array/dict # How **Note**: this change might negatively affect conversion performance, but I'm unsure how big the impact of using [`convertFunctionResult()`](https://github.com/expo/expo/blob/bf5c4aefbf6b67f37f5f6870a6f80c2efa4c8171/packages/expo-modules-core/ios/Core/Conversions.swift#L182) is. - Updated array dynamic type's convertResult to use `Conversions.convertFunctionResult()` which respects value types - Added `convertResult` to dictionary dynamic type as it was missing there # Test Plan - Tested on the SQLite stack (#42642) which required this change. - Added unit test for `DynamicArrayType` and a test suite for `DynamicDictionaryType` # Checklist - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )