bevacqua/react-dragula

How to use it in `typescript`?

zhaoyi0113 opened this issue ยท 5 comments

I get an error Could not find a declaration file for module 'react-dragula' when using react-dragula in typescript. Where can I find the type definition for this component?

Would you support typescript if it's possible? @bevacqua

Simply create an index.d.ts file and add these lines:

declare module 'react-dragula' {
    export default function(
        containers: Array<HTMLElement>,
        options: import('dragula').DragulaOptions
    ): import('dragula').Drake;
}

and run yarn add @types/dragula --dev or npm install @types/dragula --save-dev

It'd be great if this was just included in the package!

@JoshMcCullough your comment gave me the idea to add the type definition to the DefinitelyTyped repository. My PR just got merged: DefinitelyTyped/DefinitelyTyped#46828 (comment)

So now you can just run yarn add @types/react-dragula or npm install @types/react-dragula --save, and it should work ๐ŸŽ‰

@AdrianMrn Great, thanks!