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

React Native 0.88 Strict TS API Incompatibility

未关闭
#741 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
2.8k
派生
258
平均合并
3 天 1 小时
30 天内合并 PR
2

描述

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)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。