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

TypeScript support #34

Closed
tanftw opened this issue Oct 25, 2019 · 6 comments
Closed

TypeScript support #34

tanftw opened this issue Oct 25, 2019 · 6 comments

Comments

@tanftw
Copy link

tanftw commented Oct 25, 2019

Hi George, do you have any planning for TypeScript support?

@primetwig
Copy link
Owner

I'd like to have it, but I do not maintain it a lot at the moment. Any help is welcome.

@p8ul
Copy link

p8ul commented Jun 14, 2020

In your root folder add this folders @types/react-nestable then add a index.d.ts. Copy the code below in the file.

declare module 'react-nestable' {
  import * as React from 'react';

  export type Item = {
    id: string;
    text: string;
    children?: Item[];
    nestedIn?: string | null;
    link?: string | null;
    type?: number;
  };
  export default class Nestable extends React.Component<{
    items: Item[];
    handler?: React.ReactNode;
    renderItem: (arg: {
      item: Item;
      collapseIcon: React.ReactNode;
      index: number;
      handler: React.ReactNode;
    }) => React.ReactNode;
    maxDepth: number;
    renderCollapseIcon?: (args: { isCollapsed: boolean }) => React.ReactNode;
    onChange: (items: Item[]) => void;
    confirmChange: (dragItem: Item, destinationParent: Item) => boolean;
  }> {}
}

@herudi
Copy link

herudi commented Jul 11, 2020

In your root folder add this folders @types/react-nestable then add a index.d.ts. Copy the code below in the file.

declare module 'react-nestable' {
  import * as React from 'react';

  export type Item = {
    id: string;
    text: string;
    children?: Item[];
    nestedIn?: string | null;
    link?: string | null;
    type?: number;
  };
  export default class Nestable extends React.Component<{
    items: Item[];
    handler?: React.ReactNode;
    renderItem: (arg: {
      item: Item;
      collapseIcon: React.ReactNode;
      index: number;
      handler: React.ReactNode;
    }) => React.ReactNode;
    maxDepth: number;
    renderCollapseIcon?: (args: { isCollapsed: boolean }) => React.ReactNode;
    onChange: (items: Item[]) => void;
    confirmChange: (dragItem: Item, destinationParent: Item) => boolean;
  }> {}
}

Cool . . Great thanks...

@herudi
Copy link

herudi commented Jul 11, 2020

Now, to support typescript i'm install from here
yarn add https://github.com/primetwig/react-nestable/archive/8455e656aa8d7e379042517bf50505d446a78f88.tar.gz

@jezswift
Copy link

jezswift commented Jan 7, 2021

Hi @primetwig , any chance you could quickly include the type defs created by @herudi in the dist folder.
This would be a great and hopefully a quick fix.

Many thanks in advance,

@primetwig
Copy link
Owner

done in 2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants