ng2-dragula
ng2-dragula copied to clipboard
[usage question] DragulaOptions
- [x] My issue title starts with
[usage question] - [x] I have read the README, especially the 'classic blunders' section
- [x] I have looked at the demos to see if my use case has obvious examples.
- [x] I have searched the
ng2-dragulaissues, including closed issues. - [x] I have browsed the issues labeled "future reference" for problems that have been solved before.
Use case description (required) What to use DragulaOptions
Additional context
Following the README
dragulaService.createGroup("VAMPIRES", {
removeOnSpill: true
});
I get the following error:
error TS2345: Argument of type '{ removeOnSpill: boolean; }' is not assignable to parameter of type 'DragulaOptions<any>'.
Object literal may only specify known properties, and 'removeOnSpill' does not exist in type 'DragulaOptions<any>'.
You don’t have @types/dragula’. Get the latest version of Ng2-Dragula, and it will be installed. If that’s not it, I can’t help you.
https://github.com/valor-software/ng2-dragula/blob/master/modules/ng2-dragula/src/DragulaOptions.ts
I do have that installed. I did upgrade from 1.5 to 2.1
Just tried to remove my whole node_modules folder and reinstall everything.. Still gets same error
Maybe a typescript upgrade is in order
Also probably some typeRoots settings in your tsconfig
Basically, this stuff works in new Angular apps, so there’s something wrong with the way your types/dragula is being resolved or installed.
I have same error. Everything working as expected, but this error popup in the terminal. I also moved from 1.5 to 2.1.
error TS2345: Argument of type '{ moves: (el: any, container: any, handle: any) => boolean; }' is not assignable to parameter of type 'DragulaOptions<any>'.
Object literal may only specify known properties, and 'moves' does not exist in type 'DragulaOptions<any>'.
Can you import directly from @types/dragula? i.e.
import { DragulaOptions } from 'dragula';
const x: DragulaOptions = {
moves: () => true,
};
As I posted above, ng2-dragula depends directly on those type defs, and the DragulaOptions<T> exported by this library just extend the originals, so all properties from @types/dragula are available. Unless your typescript isn't picking up the appropriate * => @types/* implicit mapping through the typeRoots compiler option.
Works for me, thanks
OK, after a few lost hours, I managed to have it working thanks to @cormacrelf : `
import { DragulaService } from '../../../../node_modules/ng2-dragula'; import { DragulaOptions } from 'dragula'; ... constructor(
...,
private dragulaService: DragulaService) {
let options: DragulaOptions = {
moves: (el, source, handle) => handle.className.includes('drag-handle')
}
this.dragulaService.createGroup("steps-bag", options);
}`
Thank you @mythcyrax for sharing this solution, works great
I just did an npm install @types/ng2-dragula@latest and that did the trick.
Or so I thought. It just got me into another set of failures.