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

Missing types typescript #12

Closed
RonJonesTalitrix opened this issue Feb 12, 2023 · 6 comments
Closed

Missing types typescript #12

RonJonesTalitrix opened this issue Feb 12, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@RonJonesTalitrix
Copy link

Hello,
I am working in an existing React Native project and trying to implement 'react-native-credit-card-input-plus".
I have followed every step in the readme however I am getting the following error on the import statement

Could not find a declaration file for module 'react-native-credit-card-input-plus'. '/Users/ronjones/talitrix-cms/node_modules/react-native-credit-card-input-plus/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/react-native-credit-card-input-plus if it exists or add a new declaration (.d.ts) file containing `declare module 'react-native-credit-card-input-plus';

I have tried creating an index.d.ts file and placing the declare module there which removes the error but then fails on run with the following error

Unable to resolve module AccessibilityInfo from /Users/ronjones/talitrix-cms/node_modules/react-native-credit-card-input-plus/node_modules/react-native/Libraries/react-native/react-native-implementation.js: AccessibilityInfo could not be found within the project or in these directories:
node_modules/react-native-credit-card-input-plus/node_modules
node_modules

Any help would be greatly appreciated as I am new to react native

@juandl juandl changed the title Error when trying to import CreditCardInput Missing types typescript Feb 12, 2023
@juandl juandl added the enhancement New feature or request label Feb 12, 2023
@juandl juandl self-assigned this Feb 13, 2023
@RonJonesTalitrix
Copy link
Author

Is there any timeline on this? Just seeing when I may be able to release with this feature

@juandl
Copy link
Owner

juandl commented Feb 19, 2023

@RonJonesTalitrix hopefully this week

@RonJonesTalitrix
Copy link
Author

@juandl ok awesome, thank you so much

@thedentor
Copy link

Hey @juandl Any update regarding what was commented by @RonJonesTalitrix

@CommanderAlchemy
Copy link

CommanderAlchemy commented Jun 14, 2023

I have played a bit just by looking at the docs and outputs bit quick, seems to work but I havent fully tested it so don't take this as complete.

declare module 'react-native-credit-card-input-plus' {
    import { StyleProp, ViewStyle, TextStyle } from 'react-native';

    enum Status {
        Incomplete = "incomplete",
        Valid = "valid",
        Invalid = "invalid",
    }
    
    interface CreditCard {
        number:string,
        cvc: number,
        expiry:string,
        type:string
    }
    
    interface CreditCardFormData {
        status: {
            cvc: Status;
            expiry: Status;
            number: Status;
        };
        valid: boolean;
        values: CreditCard
    }
    
    interface Labels {
        number: string;
        expiry: string;
        cvc: string;
    }

    interface Placeholders {
        number: string;
        expiry: string;
        cvc: string;
    }
    
    interface CustomIcons {
        [key: string]: any; // Replace any with the type of your image import e.g. ImageSourcePropType
    }
    
    interface CardViewProps {
        focused?: string;
        clickable?: boolean;
        brand?: string;
        name?: string;
        number?: string;
        expiry?: string;
        cvc?: string;
        placeholder?: Placeholders;
        scale?: number;
        fontFamily?: string;
        imageFront?: number;
        imageBack?: number;
        customIcons?: CustomIcons;
    }

    interface CreditCardInputProps {
        autoFocus?: boolean;
        onChange?: (data: CreditCardFormData) => void;
        onFocus?: (name: string) => void;
        labels?: Labels;
        placeholders?: Placeholders;
        cardScale?: number;
        cardFontFamily?: string;
        cardImageFront?: number;
        cardImageBack?: number;
        labelStyle?: StyleProp<TextStyle>;
        inputStyle?: StyleProp<TextStyle>;
        inputContainerStyle?: StyleProp<ViewStyle> | Array<StyleProp<ViewStyle>>;
        validColor?: string;
        invalidColor?: string;
        placeholderColor?: string;
        requiresName?: boolean;
        requiresCVC?: boolean;
        requiresPostalCode?: boolean;
        validatePostalCode?: (value: string) => Status;
        allowScroll?: boolean;
        horizontalScroll?: boolean;
        cardBrandIcons?: CustomIcons;
        additionalInputsProps?: { [key: string]: StyleProp<TextStyle> };
    }
    
    interface LiteCardInputProps {
        autoFocus?: boolean;
        onChange?: (data: CreditCardFormData) => void;
        onFocus?: (name: string) => void;
        placeholders?: Placeholders;
        inputStyle?: StyleProp<TextStyle>;
        validColor?: string;
        invalidColor?: string;
        placeholderColor?: string;
        additionalInputsProps?: { [key: string]: StyleProp<TextStyle> };
    }

    export const CreditCardInput: React.FC<CreditCardInputProps>;
    export const CardView: React.FC<CardViewProps>;
    export const LiteCreditCardInput: React.FC<LiteCardInputProps>;
}`

@juandl
Copy link
Owner

juandl commented Apr 2, 2024

Issues solved , open a separated issue for types

@juandl juandl closed this as completed Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants