ng2-dragula: [bug report] Types definition issue
Describe the bug (required)
When i run tsc on my project i get:
/node_modules/ng2-dragula/dist/MockDrake.d.ts, line: 22
Class 'MockDrake' incorrectly implements interface 'DrakeWithModels'. Types of property 'on' are
incompatible. Type '(event: string, callback: Function) => void' is not assignable to type '(events: string,
callback: Function) => Drake'. Type 'void' is not assignable to type 'Drake'.
L22: export declare class MockDrake implements DrakeWithModels {
L23: containers: Element[];
To Reproduce (required)
Install the packages at the version below and run tsc
Versions (required)
- “@angular/core”: “5.2.11”
- “ng2-dragula”: “2.1.0”
- “typescript”: “2.6.2”
- @types/dragula@2.1.34
If i change the line 42 of node_modules\ng2-dragula\dist\MockDrake.d.ts from
on(event: string, callback: Function): void;
to
on(event: string, callback: Function): Drake;
everything works
Also see: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15422
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 17 (2 by maintainers)
Commits related to this issue
- Fixed #912 [bug report] Types definition issue by changing return type from void to any. — committed to wendelstam/ng2-dragula by wendelstam 6 years ago
- Fix for #912 — committed to vesrah/ng2-dragula by vesrah 6 years ago
Same issue here using:
Error when building:
ERROR in node_modules/ng2-dragula/dist/MockDrake.d.ts(41,5): error TS2416: Property 'on' in type 'MockDrake' is not assignable to the same property in base type 'DrakeWithModels'. Type '(event: string, callback: Function) => void' is not assignable to type '(events: string, callback: Function) => Drake'. Type 'void' is not assignable to type 'Drake'.Guys. Patch released. But please read.
The reason many libs use semver for secondary dependencies is twofold: so that other dependents can be satisfied using the same resolved version, and so that we don’t need to run a patch release every time a dep changes. Library authors push the responsibility for reproducible builds onto consumers. That’s you. If you don’t do this job, you will get problems. This is how it works for almost every single NPM package.
Yarn and package-lock.json were invented to do the job for you. Every JS developer needs to be using one of them because trusting semver for your own production releases is plain irresponsible.
I can’t even reproduce this without implementing the workaround(s) in reverse. Please everyone check that you have that and it’s working, and that you aren’t doing
rm yarn.lockjust to get upgrades (useyarn upgrade-interactiveinstead).If you do, we’ll all be less frustrated by issues like this. I know the comments here represent a small proportion of total downloads, so looks like everyone else is OK.
Big up to @rkgoswami for suggesting we open an issue on bevacqua/dragula though. Hilarious.
Not sure if you mean to add it as a dependency or a resolution but the resolution fixed it for me.
try to change in /node_modules/ng2-dragula/dist/MockDrake.d.ts line 41 on(event: string, callback: Function): void; to on(event: string, callback: Function): any; that worked for me