Skip to content

React Native 0.88 Strict TS API Incompatibility #741

Description

@leotm

Spotted couple things upgrading RN 0.87.0-nightly to 0.88.0-nightly, for context

RN 0.88 includes a breaking change

both tsgo and classic tsc with skipLibCheck: true skip .d.ts declarations

but not .ts/.tsx src files in node_modules

yarn run tsgo
node_modules/react-native-safe-area-context/src/SafeArea.types.ts:46:3 - error TS2344: Type 'HostComponent<NativeProps>' does not satisfy the constraint 'abstract new (...args: any) => any'.
  Type 'HostComponent<NativeProps>' provides no match for the signature 'new (...args: any): any'.

46   typeof NativeSafeAreaView
     ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/react-native-safe-area-context/src/SafeAreaContext.tsx:122:24 - error TS7006: Parameter 'e' implicitly has an 'any' type.

122       onInsetsChange={(e) => {
                           ~

node_modules/react-native-safe-area-context/src/specs/NativeSafeAreaProvider.ts:4:8 - error TS2307: Cannot find module 'react-native/Libraries/Types/CodegenTypes' or its corresponding type declarations.

4 } from 'react-native/Libraries/Types/CodegenTypes';
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/react-native-safe-area-context/src/specs/NativeSafeAreaProvider.ts:5:36 - error TS2307: Cannot find module 'react-native/Libraries/Utilities/codegenNativeComponent' or its corresponding type declarations.

5 import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/react-native-safe-area-context/src/specs/NativeSafeAreaView.ts:1:36 - error TS2307: Cannot find module 'react-native/Libraries/Utilities/codegenNativeComponent' or its corresponding type declarations.

1 import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/react-native-safe-area-context/src/specs/NativeSafeAreaView.ts:2:34 - error TS2307: Cannot find module 'react-native/Libraries/Types/CodegenTypes' or its corresponding type declarations.

2 import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 6 errors in 4 files.

Errors  Files
     1  node_modules/react-native-safe-area-context/src/SafeArea.types.ts:46
     1  node_modules/react-native-safe-area-context/src/SafeAreaContext.tsx:122
     2  node_modules/react-native-safe-area-context/src/specs/NativeSafeAreaProvider.ts:4
     2  node_modules/react-native-safe-area-context/src/specs/NativeSafeAreaView.ts:1

which affects react-native-safe-area-context@5.8.0

the workaround is for apps to opt out

// tsconfig.json
{
  "extends": "@react-native/typescript-config",
  "compilerOptions": {
    ...
    "customConditions": ["react-native-legacy-deep-imports"]
  }
}

or patch the breaking changes which can be dealt with by either patching
(simpler) package.json
or
the src files (including the type declarations if skipLibCheck is false)

i'll raise both sub-issues with this as parent then link both PRs

(upstream template is on react-native-safe-area-context ^5.5.2, so next ver bump w the fixes will get picked up)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions