Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug report] Types definition issue #912

Closed
fttx opened this issue Oct 27, 2018 · 17 comments
Closed

[bug report] Types definition issue #912

fttx opened this issue Oct 27, 2018 · 17 comments

Comments

@fttx
Copy link

fttx commented Oct 27, 2018

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/[email protected]

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: DefinitelyTyped/DefinitelyTyped#15422

@chris246
Copy link

Same issue here using:

  • "@angular/core": "6.1.6",
  • "ng2-dragula": "2.0.4",
  • "typescript": "2.9.2"
  • @types/[email protected]

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'.

@Mohendran
Copy link

@fttx
Same Issue here...

However, It worked for me when I used @types/[email protected]

@chris246 check your package-lock.json file for the version number.

@daiyis
Copy link

daiyis commented Oct 29, 2018

same issue. Manually add "@types/dragula": "2.1.33" into package.json fixed on my side.

@joshstrohminger
Copy link

Not sure if you mean to add it as a dependency or a resolution but the resolution fixed it for me.

"resolutions": {
    "@types/dragula": "2.1.33"
}

@urdenko
Copy link

urdenko commented Oct 29, 2018

This problem is very relevant now. Please fix it as soon as possible.

@lisa13
Copy link

lisa13 commented Oct 29, 2018

I am using angular 6 so I can't exactly go back to an older version of angular just for the sake of using dragula.
One solution that worked for us was to:

in the node_modules\ng2-dragula\dist\MockDrake.d.ts file,
import { Drake } from 'dragula';

then in the same file on the line 41 change:
on(event: string, callback: Function): void;
to
on(event: string, callback: Function): Drake;

wendelstam added a commit to wendelstam/ng2-dragula that referenced this issue Oct 29, 2018
@wendelstam
Copy link

I have made a change in a branch, I will test it later today and if it works I will submit a PR
(https://github.com/wendelstam/ng2-dragula/blob/master/modules/ng2-dragula/src/MockDrake.ts)

@nadeemgori2
Copy link

@wendelstam
here return type should be void
on(event: string, callback: Function): any {
}

@chris246
Copy link

Adding the resolution from #912 (comment) worked for me

@sharvarilimbkar
Copy link

sharvarilimbkar commented Oct 29, 2018

@wendelstam still same issue. after your commit. issue is in
node_modules/ng2-dragula/dist/MockDrake.d.ts
in Drake interface on(event: string, callback: Function) return type Drake

and in MockDrake.d.ts this file
on(event: string, callback: Function) return type void

vesrah added a commit to vesrah/ng2-dragula that referenced this issue Oct 29, 2018
@vesrah vesrah mentioned this issue Oct 29, 2018
3 tasks
@mnolan98-usf
Copy link

How soon will this be fixed? If you're not going to pin to a very specific version you need to really make sure you aren't breaking others. I'm days away from a production deployment and need to make a small configuration change that I can no longer get a build working for due to this issue.

@cormacrelf
Copy link
Contributor

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.lock just to get upgrades (use yarn upgrade-interactive instead).

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.

@fttx
Copy link
Author

fttx commented Nov 1, 2018

There is so much information on npm that it's easy to miss the important things and don't see the big picture, thanks

@katkoorishruthi
Copy link

Hi,
I am not able to fix the issue after updating to 2.1.33
can you suggest me plz!!

@cormacrelf
Copy link
Contributor

Oh, and you guys are going to have to remove the workarounds you’ve done.

@mohamedbrahimi
Copy link

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

@desoga10
Copy link

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

This also worked for me now. After almost two days of no progress. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests