appandflow / appandflow/react-native-safe-area-context

React Native 0.88 Strict TS API Incompatibility

Đang mở
#741 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
2.8k
Fork
258
Merge trung bình
3 ngày 1 giờ
Pull request đã merge (30 ngày)
2

Mô tả

Spotted couple things upgrading RN 0.87.0-nightly to 0.88.0-nightly, for context
- https://github.com/leotm/react-native-template-new-architecture/issues/2031
- https://github.com/leotm/react-native-template-new-architecture/pull/2040
- https://github.com/leotm/react-native-template-new-architecture/issues/2041

RN 0.88 includes a breaking change
- https://github.com/react/react-native/pull/57490

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' does not satisfy the constraint 'abstract new (...args: any) => any'.
Type 'HostComponent' 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

> ```js
> // 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)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.