fix(codegen): inline imported type refs in NativeA0Auth0 spec (#1553)#1555
Open
benjaminkomen wants to merge 1 commit into
Open
fix(codegen): inline imported type refs in NativeA0Auth0 spec (#1553)#1555benjaminkomen wants to merge 1 commit into
benjaminkomen wants to merge 1 commit into
Conversation
…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
6 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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 everyTSTypeReferenceto imported / aliased types in NativeModule specs:This blocks both iOS
pod installand the Android:react-native-auth0:generateCodegenSchemaFromJavaScriptGradle 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:
codegenConfigfrompackage.json(mirroring fix: Interop Layer #1037).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
codegenConfigworking today and leaves the door open for a full TurboModule migration later (a follow-up that would tightenObjectback into proper schemas, but that work depends on Codegen accepting type aliases first).Mapping
Int32(locally aliased tonumber)numberPromise<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 }ObjectThe
Credentials/ApiCredentials/LocalAuthenticationOptionstypes are still exported fromsrc/typesand 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:NSInteger/Double/Int, so the JS-side widening fromInt32tonumberdoesn't change what reaches native code,localAuthenticationOptions,saveCredentials,additionalParameters,parameters,headers,userMetadata) as untypedNSDictionary/ReadableMap, so collapsing them toObjectmatches what was already being read.Validation
Validated downstream on an Expo SDK 56 / RN 0.85.3 app:
patch-package, iOS Codegen +pod installsucceed,:react-native-auth0:generateCodegenSchemaFromJavaScriptandassembleDebugsucceed,EXC_BAD_ACCESS, login flow works end-to-end).The same patch text is also posted as a
patch-packagesnippet in #1553 so other affected users can apply it locally while this PR is being reviewed.Notes for reviewers
{ idToken: string; accessToken: string; ... }shapes for the credential return types (instead ofObject). RN's Codegen accepts those, but it would re-introduceTSTypeReference-style schemas in the generated headers and the native side already returns plainNSDictionarys — so the inline shapes would only buy compile-time strictness without unlocking real TurboModule semantics. Happy to switch to that if the maintainers prefer.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.