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

Add typescript types #197

Open
jacob-leger opened this issue Nov 3, 2023 · 7 comments
Open

Add typescript types #197

jacob-leger opened this issue Nov 3, 2023 · 7 comments

Comments

@jacob-leger
Copy link

I'm always frustrated when I don't have Typescript types. Everyone uses TS, and this library should too.

Could you please add Typescript? It's not even that hard, and it can be done slowly and incrementally.

I believe this is the MOST important thing to do with this library at the moment, and I am willing to help too.

@giorgosart
Copy link
Owner

Hi @Leiloukou thanks for creating this ticket!

I don't really know how to do that so feel free to create a PR with the changes you need and then I'll follow your lead?

@jacob-leger
Copy link
Author

I am not familiar with this library and have never even used it before, but I would be happy to help in the near future. I am currently working on a personal project as well as school, but I will try to help as soon as I can. I will probably be free in December, as I will have less school. See you then!

@jacob-leger
Copy link
Author

Update: I'm a little busy, but I still want to help. I might be able to in the near future, sorry 😞

@jayanti-prajapati
Copy link

jayanti-prajapati commented Jul 17, 2024

@Leiloukou You can create a custom type declaration file for now to use with typescript.

  1. Create a new file named react-easy-edit.d.ts in your src directory (or in a types directory if you have one).
  2. Add the following declaration inside the react-easy-edit.d.ts file:
declare module 'react-easy-edit' {
  import * as React from 'react';

  export interface EasyEditProps {
    type: 'text' | 'textarea' | 'number' | 'date' | 'time' | 'select';
    onSave: (value: any) => void;
    onCancel?: () => void;
    value: any;
    saveButtonLabel?: string;
    cancelButtonLabel?: string;
    attributes?: object;
    instructions?: string;
    placeholder?: string;
    validationMessage?: string;
    allowEdit?: boolean;
    viewAttributes?: object;
    editAttributes?: object;
    options?: Array<{ label: string, value: any }>;
    hideIcons?: boolean;
    buttonsPosition?: 'before' | 'after';
    saveButtonStyle?: object;
    cancelButtonStyle?: object;
    saveButtonClassName?: string;
    cancelButtonClassName?: string;
    validation?: (value: any) => boolean;
  }

  const EasyEdit: React.FC<EasyEditProps>;

  export default EasyEdit;
  export const Types: {
    TEXT: 'text';
    TEXTAREA: 'textarea';
    NUMBER: 'number';
    DATE: 'date';
    TIME: 'time';
    SELECT: 'select';
  };
}

@jacob-leger
Copy link
Author

@Leiloukou You can create a custom type declaration file for now to use with typescript.

Thank you ❤️

@spacecat
Copy link

It would be nice indeed to add a declaration file. Getting the following in VSCode currently:

Could not find a declaration file for module 'react-easy-edit'. '/xyz/node_modules/react-easy-edit/build/react-easy-edit.min.js' implicitly has an 'any' type.
Try npm i --save-dev @types/react-easy-edit if it exists or add a new declaration (.d.ts) file containing declare module 'react-easy-edit';ts(7016)

@veyDer
Copy link

veyDer commented Nov 4, 2024

It would be nice indeed to add a declaration file. Getting the following in VSCode currently:

Could not find a declaration file for module 'react-easy-edit'. '/xyz/node_modules/react-easy-edit/build/react-easy-edit.min.js' implicitly has an 'any' type. Try npm i --save-dev @types/react-easy-edit if it exists or add a new declaration (.d.ts) file containing declare module 'react-easy-edit';ts(7016)

Got here trying to sort out the exact same 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

No branches or pull requests

5 participants