Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gestureHandlerRootHOC type error props declared as an interface #2711

Closed
fxamauri opened this issue Jan 3, 2024 · 0 comments · Fixed by #2712
Closed

gestureHandlerRootHOC type error props declared as an interface #2711

fxamauri opened this issue Jan 3, 2024 · 0 comments · Fixed by #2712
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: MacOS Platform: Web Repro provided A reproduction with a snack or repo is provided

Comments

@fxamauri
Copy link
Contributor

fxamauri commented Jan 3, 2024

Description

When I have a component with props that was declared as an interface, this error occurs

Argument of type '({ children }: MyCmpProps) => React.JSX.Element' is not assignable to parameter of type 'ComponentType<Record<string, unknown>>'.
  Type '({ children }: MyCmpProps) => React.JSX.Element' is not assignable to type 'FunctionComponent<Record<string, unknown>>'.
    Types of parameters '__0' and 'props' are incompatible.
      Property 'children' is missing in type 'Record<string, unknown>' but required in type 'MyCmpProps'.ts(2345)

Steps to reproduce

check type

import { View } from 'react-native';
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';

interface MyCmpProps {
  children: React.ReactNode;
}

const MyCmp = ({ children }: MyCmpProps) => <View>{children}</View>;

const ExampleWithHoc = gestureHandlerRootHOC(MyCmp);

Snack or a link to a repository

https://snack.expo.dev/@fx_amauri/graceful-violet-scone

Gesture Handler version

2.14.0

React Native version

0.73.1

Platforms

Android, iOS, Web, MacOS

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: MacOS Platform: Web Repro provided A reproduction with a snack or repo is provided labels Jan 3, 2024
m-bert added a commit that referenced this issue Jan 4, 2024
## Description

While looking at #2711 we decided to change `P extends Record<string, unknown>` to `P extends object` (issue author already created #2712). However, current CI won't allow this change because of `ban-types` eslint rule. I've decided to follow @tjzel suggestion and change this rule to warning instead of error.

## Test plan

Run `yarn lint:js-root`.
@m-bert m-bert closed this as completed in b4eba25 Jan 5, 2024
j-piasecki pushed a commit that referenced this issue Jan 12, 2024
## Description

fix gestureHandlerRootHOC type error props declared as an interface


Fixes #2711

## Test plan

Check type gestureHandlerRootHOC

---------

Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: MacOS Platform: Web Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant