How to use it in `typescript`?
zhaoyi0113 opened this issue ยท 5 comments
zhaoyi0113 commented
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?
AdrianMrn commented
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
JoshMcCullough commented
It'd be great if this was just included in the package!
AdrianMrn commented
@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 ๐
JoshMcCullough commented
@AdrianMrn Great, thanks!