ng2-dragula: Property 'on' in type 'MockDrake' is not assignable to the same property in base type 'DrakeWithModels'

This issue was not there when I started using this library but later on, found this issue (shown in attachment below): dragula-bug

Issue is very simple:

  • Drag interface has a method on(events: string, callback: Function): Drake; => file index.d.ts
  • Interface DrakeWithModels extends Drake
  • Class MockDrake implements DrakeWithModels, where method on(events: string, callback: Function): void; is overriden but the return type is changed, which is not allowed.

Fix is simple change the return type for method on in Interface Drag to void;

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 18
  • Comments: 27 (1 by maintainers)

Most upvoted comments

I’ve solved this problem by adding "@types/dragula": "2.1.33", to my package.json

I did npm install @types/dragula@2.1.33 --save-dev and it solved the issue on my side

@mba3gar are you sure you installed 2.1.33? you can run npm install @types/dragula@2.1.33 --save-dev again to be sure (and I would set it as dev dependency) …

I’ve solved this problem by @angular/cdk/drag-drop

100% solution “ng2-dragula”: “2.0.0”, “@types/dragula”: “2.1.33”

Since ng2-dragula@2.0.1 and great has dependencies “@types/dragula”: “^2.1.33”. In this case we will have version 2.1.34

@petterlabraaten can you tell me how to do it ? because i can’t find the @types/dragula in my package.json

Go to your package.json of your project and add "@types/dragula": "2.1.33" into your "dependencies": { } . And the do, npm i or you can do as suggested by @skydever

@adlerzz 's solution definitely helped

ng2-dragula@2.1.0 expects @types/dragula@^2.1.33, so I solved it by globally uninstalling @types/dragula (which was version 2.1.34) and installing 2.1.33 instead.

If you go with Yarn add this as a workaround to your package.json:

  "resolutions": {
    "ng2-dragula/**/@types/dragula": "2.1.33"
  }

same problem angular 7.0.0