Skip to content

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

@elliottkember

Description

@elliottkember

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions