Skip to content

fix(codegen): inline imported type refs in NativeA0Auth0 spec (#1553)#1555

Open
benjaminkomen wants to merge 1 commit into
auth0:masterfrom
benjaminkomen:fix/codegen-imported-types-1553
Open

fix(codegen): inline imported type refs in NativeA0Auth0 spec (#1553)#1555
benjaminkomen wants to merge 1 commit into
auth0:masterfrom
benjaminkomen:fix/codegen-imported-types-1553

Conversation

@benjaminkomen
Copy link
Copy Markdown

@benjaminkomen benjaminkomen commented May 31, 2026

Description

Closes #1553.

react-native-auth0's TurboModule spec (src/specs/NativeA0Auth0.ts) currently uses imported / aliased type references (Credentials, ApiCredentials) and indexed-signature object types ({ [key: string]: string | Int32 | boolean }). On RN 0.85+ — the React Native version that ships with Expo SDK 56 — Codegen has tightened its grammar and now rejects every TSTypeReference to imported / aliased types in NativeModule specs:

[Codegen] Processing RNAuth0Spec
[Codegen] UnsupportedTypeAnnotationParserError: Module NativeA0Auth0:
TypeScript type annotation 'TSTypeReference' is unsupported in NativeModule specs.

This blocks both iOS pod install and the Android :react-native-auth0:generateCodegenSchemaFromJavaScript Gradle task on RN 0.85 with the New Architecture — which is the Expo SDK 56 default — making the library effectively unusable on the latest RN/Expo for any project that relies on Codegen running.

Approach — Option B from #1553

The reporter laid out two options:

  • Option A: drop codegenConfig from package.json (mirroring fix: Interop Layer #1037).
  • Option B: keep codegenConfig, but make the spec Codegen-friendly by replacing imported / aliased types with inline primitives, Object, or inline object literals.

This PR implements Option B. Rationale: Option A is a strictly weaker fix — it disables Codegen processing entirely and gives up the road to native TurboModules. Option B keeps codegenConfig working today and leaves the door open for a full TurboModule migration later (a follow-up that would tighten Object back into proper schemas, but that work depends on Codegen accepting type aliases first).

Mapping

Before After
Int32 (locally aliased to number) number
Promise<Credentials> Promise<Object>
Promise<ApiCredentials> Promise<Object>
Promise<{ ...inline... }> Promise<Object>
{ [key: string]: string | Int32 | boolean } Object
{ [key: string]: string | Int32 } Object
{ [key: string]: string } Object

The Credentials / ApiCredentials / LocalAuthenticationOptions types are still exported from src/types and used by the public JS API (CredentialsManager, WebAuth wrappers, etc.). Only the bridge spec is inlined — the user-facing surface is unchanged.

No runtime change

The native iOS (A0Auth0.mm / NativeBridge.swift) and Android (A0Auth0Module.kt) implementations already:

  • coerce numeric arguments through NSInteger / Double / Int, so the JS-side widening from Int32 to number doesn't change what reaches native code,
  • treat the option dictionaries (localAuthenticationOptions, saveCredentials, additionalParameters, parameters, headers, userMetadata) as untyped NSDictionary / ReadableMap, so collapsing them to Object matches what was already being read.

Validation

Validated downstream on an Expo SDK 56 / RN 0.85.3 app:

  • with this patch applied via patch-package, iOS Codegen + pod install succeed,
  • Android :react-native-auth0:generateCodegenSchemaFromJavaScript and assembleDebug succeed,
  • the app launches and hits Auth0 successfully on a physical iPhone (no EXC_BAD_ACCESS, login flow works end-to-end).

The same patch text is also posted as a patch-package snippet in #1553 so other affected users can apply it locally while this PR is being reviewed.

Notes for reviewers

  • I considered tightening to inline { idToken: string; accessToken: string; ... } shapes for the credential return types (instead of Object). RN's Codegen accepts those, but it would re-introduce TSTypeReference-style schemas in the generated headers and the native side already returns plain NSDictionarys — so the inline shapes would only buy compile-time strictness without unlocking real TurboModule semantics. Happy to switch to that if the maintainers prefer.
  • Alternative Option A (drop codegenConfig) is a one-line change and would also close codegenConfig breaks iOS pod install on New Architecture (RN 0.85+) — TSTypeReference in NativeA0Auth0 spec #1553 — let me know if you'd rather take that path; I'm happy to repurpose the branch.

…1553)

RN 0.85's stricter Codegen rejects any TSTypeReference to imported /
aliased types in NativeModule specs:

    UnsupportedTypeAnnotationParserError: Module NativeA0Auth0:
    TypeScript type annotation 'TSTypeReference' is unsupported in
    NativeModule specs.

Currently the spec imports `Credentials` / `ApiCredentials` from
'../types' and uses indexed-signature object types (e.g.
`{ [key: string]: string | Int32 | boolean }`). Both shapes break iOS
`pod install` and the Android `:react-native-auth0:generateCodegenSchemaFromJavaScript`
task on RN 0.85 with the New Architecture (the Expo SDK 56 default), as
reported in auth0#1553.

Apply Option B from auth0#1553: rewrite the spec so all return / parameter
types are codegen-compatible inline primitives, `Object`, or inline
object literals. Specifically:

  Int32                                        -> number
  Promise<Credentials>                         -> Promise<Object>
  Promise<ApiCredentials>                      -> Promise<Object>
  Promise<{ ... inline ... }>                  -> Promise<Object>
  { [key: string]: string | Int32 | boolean }  -> Object
  { [key: string]: string | Int32 }            -> Object
  { [key: string]: string }                    -> Object

The native iOS / Android implementations already coerce these to
NSInteger / Double and treat the option dictionaries as untyped maps,
so this is a type-level change only — no runtime behavior shifts.
The `Credentials` / `ApiCredentials` / `LocalAuthenticationOptions`
types remain part of the public JS API surface; only the bridge spec
is inlined.

Validated locally on a downstream Expo SDK 56 / RN 0.85.3 app
(installer-app, com.generac.ces.installerapp.dev): with this patch
applied via patch-package, codegen succeeds on iOS and Android, and
the app launches and hits Auth0 successfully on a physical iPhone.

Closes auth0#1553
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codegenConfig breaks iOS pod install on New Architecture (RN 0.85+) — TSTypeReference in NativeA0Auth0 spec

1 participant