Fix NoCodes TurboModule spec failing Codegen on React Native 0.84+#446
Fix NoCodes TurboModule spec failing Codegen on React Native 0.84+#446NickSxti wants to merge 1 commit into
Conversation
The NoCodes TurboModule spec typed the `onNoCodeEvent` emitter payload as
a union of types imported from `../Mapper`. React Native Codegen only
resolves types declared inside the spec file, and since RN 0.84 it fully
descends into an event emitter's payload type alias. It therefore cannot
resolve the imported `QNoCodeAction` and throws:
UnsupportedGenericParserError: Module NativeNoCodesModule:
Unrecognized generic type 'QNoCodeAction' in NativeModule spec.
This aborts `pod install` for every New Architecture app on RN 0.84+
(iOS and Android), regardless of whether the app uses No-Codes, because
Codegen processes the whole spec directory at build time. RN 0.82+ no
longer lets apps opt out of the New Architecture, so there is no escape
hatch.
Type `onNoCodeEvent` as `EventEmitter<Object>`, matching every other
emitter in the SDK (`onNoCodePurchase`, `onEntitlementsUpdated`, ...),
and move the `NoCodeEvent` payload type to its only consumer
(`NoCodesInternal`). The native boundary now carries an opaque payload
that Codegen resolves natively; the handler casts it back in the JS
layer, exactly as `customPurchaseHandler` already does. Runtime is
unchanged - native still emits a `{ name, payload }` dictionary.
Verified with @react-native/codegen 0.85.3: the spec parses with all
three emitters preserved (`onNoCodeEvent`, `onNoCodePurchase`,
`onNoCodeRestore`); typecheck and unit tests pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@SpertsyanKM could you review this when you get a chance? It fixes the React Native Codegen failure that breaks The fix types |
Problem
Installing the SDK in a New Architecture app on React Native 0.84+ fails at the Codegen step, aborting
pod install(and the Android Codegen task) with:This happens for every New Architecture app on RN 0.84+, on both iOS and Android, whether or not the app uses No-Codes, because Codegen processes the whole spec directory at build time. Since RN 0.82+ no longer allows opting out of the New Architecture, there is no workaround at the app level.
Root cause
src/internal/specs/NativeNoCodesModule.tstyped theonNoCodeEventevent-emitter payload as a union of types imported from another module:React Native Codegen resolves only the types declared inside the spec file - it does not follow
importdeclarations. Up to RN 0.83 this was latent because Codegen treated the emitter payload as an opaque alias and never descended into it. RN 0.84 changed Codegen to fully resolve an event emitter's payload type, so the importedQNoCodeActioncan no longer be resolved and Codegen throws. (The imported types are also not Codegen-representable on their own: a union of distinct object types, an intersection type, and aMap.)The sibling
NativeQonversionModulespec is unaffected because its imported types appear only inPromise<...>returns, which Codegen degrades gracefully.Fix
Type
onNoCodeEventasEventEmitter<Object>, identical to every other emitter already shipping in the SDK (onNoCodePurchase, andonEntitlementsUpdated/onDeferredPurchaseCompletedinNativeQonversionModule). TheNoCodeEventpayload type moves to its only consumer,NoCodesInternal, and the event handler casts the opaque payload back toNoCodeEventin the JS layer - the same patterncustomPurchaseHandleralready uses.The native module spec is now self-contained (it imports nothing from
../Mapper), so a future change to the mapper types cannot reintroduce this failure.Runtime impact
None. Native still emits a plain
{ name, payload }dictionary; theascasts are erased at build time. All six No-Codes listener callbacks and the purchase/restore delegate flow are unchanged. No native iOS/Android code is touched.Verification
@react-native/codegen0.85.3: the spec now parses successfully with all three emitters preserved (onNoCodeEvent,onNoCodePurchase,onNoCodeRestore); the full native generators (iOS Obj-C++, C++, Android Java/JNI) run without error. The same harness reproduces the originalUnsupportedGenericParserErroron the unpatched spec.tsc(strict): no new errors.jest: all unit tests pass.Workaround for affected users (until released)
In
node_modules/@qonversion/react-native-sdk/src/internal/specs/NativeNoCodesModule.ts, changeEventEmitter<NoCodeEvent>toEventEmitter<Object>, then runnpx patch-package @qonversion/react-native-sdkandcd ios && pod install.