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

Problems with @typescript-eslint/unbound-method #532

Open
elliottkember opened this issue Oct 19, 2024 · 0 comments · May be fixed by #533
Open

Problems with @typescript-eslint/unbound-method #532

elliottkember opened this issue Oct 19, 2024 · 0 comments · May be fixed by #533

Comments

@elliottkember
Copy link

Hello!

We started using the above lint rule @typescript-eslint/unbound-method and it's great. However the types for onOpen and onClose especially in FlagButtonProps mean that the function is defined as an unbound method rather than the fat arrow () => void method that it actually is:

    const onOpen = () => {
        setState({ ...state, visible: true });
        if (handleOpen) {
            handleOpen();
        }
    };

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-country-picker-modal/lib/FlagButton.d.ts b/node_modules/react-native-country-picker-modal/lib/FlagButton.d.ts
index d52a40f..b6be797 100644
--- a/node_modules/react-native-country-picker-modal/lib/FlagButton.d.ts
+++ b/node_modules/react-native-country-picker-modal/lib/FlagButton.d.ts
@@ -10,7 +10,7 @@ export interface FlagButtonProps {
     containerButtonStyle?: StyleProp<ViewStyle>;
     countryCode?: CountryCode;
     placeholder: string;
-    onOpen?(): void;
+    onOpen?: () => void;
 }
 export declare const FlagButton: {
     ({ withEmoji, withCountryNameButton, withCallingCodeButton, withCurrencyButton, withFlagButton, countryCode, containerButtonStyle, onOpen, placeholder, }: FlagButtonProps): JSX.Element;
diff --git a/node_modules/react-native-country-picker-modal/lib/index.d.ts b/node_modules/react-native-country-picker-modal/lib/index.d.ts
index 50bb70b..a7938d3 100644
--- a/node_modules/react-native-country-picker-modal/lib/index.d.ts
+++ b/node_modules/react-native-country-picker-modal/lib/index.d.ts
@@ -34,8 +34,8 @@ interface Props {
     renderFlagButton?(props: FlagButtonProps): ReactNode;
     renderCountryFilter?(props: CountryFilterProps): ReactNode;
     onSelect(country: Country): void;
-    onOpen?(): void;
-    onClose?(): void;
+    onOpen?: () => void;
+    onClose?: () => void;
 }
 declare const Main: {
     ({ theme, translation, ...props }: Props): JSX.Element;

This issue body was partially generated by patch-package.

@elliottkember elliottkember linked a pull request Oct 19, 2024 that will close this issue
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 a pull request may close this issue.

1 participant