Skip to content

Conversation

@subhankarmaiti
Copy link
Contributor

Fixes #1334

This PR resolves TypeScript ESLint unbound-method errors that occurred when using strict type-checking configurations with the react-native-auth0 SDK. The issue was reported when users enabled the recommended-type-checked preset from @typescript-eslint, which flagged destructured methods from the useAuth0() hook.

Changes

  1. src/hooks/Auth0Context.ts

    • Converted all 21 method signatures in Auth0ContextInterface from method syntax (methodName(): Type) to arrow function property syntax (methodName: () => Type)
    • This change signals to TypeScript and ESLint that these methods don't depend on this context and are safe to destructure
  2. src/platforms/native/bridge/NativeBridgeManager.ts

    • Updated all 13 native module method calls to use .bind(Auth0NativeModule) when passing to the a0_call wrapper
    • Ensures proper this context preservation when calling native methods
  3. eslint.config.mjs

    • Added TypeScript-specific configuration block enabling the @typescript-eslint/unbound-method rule
    • Added typescript-eslint package for unified configuration
    • Configured type-checked linting for TS/TSX files (excluding test files)
    • This ensures future code changes maintain the correct interface typing pattern
  4. package.json

    • Added typescript-eslint as a dev dependency for ESLint configuration

Testing

  • ✅ All TypeScript compilation passes
  • ✅ Verified 0 unbound-method errors with recommended-type-checked config
  • ✅ Tested destructuring patterns in example app
  • ✅ Root project linting passes with no new errors

Breaking Changes

None. This is a backward-compatible change that only affects type definitions to improve compatibility with strict TypeScript ESLint configurations.

Developer Experience Impact

Positive Impact: Developers using strict TypeScript ESLint configurations (like recommended-type-checked) can now use the SDK without linting errors when destructuring methods from the useAuth0() hook.

// This pattern now works without ESLint errors:
const { authorize, getCredentials, clearSession } = useAuth0();

@subhankarmaiti subhankarmaiti requested a review from a team as a code owner October 30, 2025 15:41
@subhankarmaiti subhankarmaiti merged commit 87d315b into master Oct 31, 2025
4 checks passed
@subhankarmaiti subhankarmaiti deleted the fix/unbound-method-typescript-eslint-issue-1334 branch October 31, 2025 06:28
@subhankarmaiti subhankarmaiti mentioned this pull request Oct 31, 2025
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.

Auth0ContextInterface has incorrect interface typing

3 participants