taye / interact.js

JavaScript drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE9+)
http://interactjs.io/
MIT License
12.32k stars 783 forks source link

Angular 13.1.1 Compile Failed #949

Closed michael-towify closed 2 years ago

michael-towify commented 2 years ago

Hi @taye ,

I met an issue, would you please help to check? Thanks in advance!

Integrate InteractJS into a new Angular project by following commands, and then compile failed.

npm i interactjs
import interact from 'interactjs'; // in app.component.ts
ng serve -o

Version

Angular: 13.1.1 InteractJS: 1.10.11 OSX: 10.15.7

Error

✔ Browser application bundle generation complete.

Initial Chunk Files   | Names         |  Raw Size
vendor.js             | vendor        |   2.00 MB |
polyfills.js          | polyfills     | 339.20 kB |
styles.css, styles.js | styles        | 212.52 kB |
main.js               | main          |  62.39 kB |
runtime.js            | runtime       |   6.87 kB |

                      | Initial Total |   2.61 MB

Build at: 2021-12-28T04:13:39.925Z - Hash: 9b59fc74801a0d28 - Time: 8507ms

Error: node_modules/@interactjs/types/index.d.ts:267:18 - error TS2428: All declarations of 'BaseEvent' must have identical type parameters.

267     export class BaseEvent<T extends ActionName | null = never> {
                     ~~~~~~~~~

Error: node_modules/@interactjs/types/index.d.ts:287:22 - error TS2428: All declarations of 'BaseEvent' must have identical type parameters.

287     export interface BaseEvent<T extends ActionName> {
                         ~~~~~~~~~

Error: node_modules/@interactjs/types/index.d.ts:2487:34 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.
  Type 'keyof ActionMap | null' is not assignable to type 'keyof ActionMap'.
    Type 'null' is not assignable to type 'keyof ActionMap'.
      Type 'T' is not assignable to type '"resize"'.
        Type 'keyof ActionMap | null' is not assignable to type '"resize"'.
          Type 'null' is not assignable to type '"resize"'.

2487         prevEvent: InteractEvent<T, EventPhase>;
                                      ~

Error: node_modules/@interactjs/types/index.d.ts:2588:135 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.

2588         _createPreparedEvent<P extends EventPhase>(event: PointerEventType, phase: P, preEnd?: boolean, type?: string): InteractEvent<T, P>;
                                                                                                                                           ~

Error: node_modules/@interactjs/types/index.d.ts:2589:64 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.

2589         _fireEvent<P extends EventPhase>(iEvent: InteractEvent<T, P>): void;
                                                                    ~

Error: node_modules/@interactjs/types/index.d.ts:2590:67 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.

2590         _doPhase<P extends EventPhase>(signalArg: Omit<DoPhaseArg<T, P>, 'iEvent'> & {
                                                                       ~

Error: node_modules/@interactjs/types/index.d.ts:2591:36 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.

2591             iEvent?: InteractEvent<T, P>;
                                        ~

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

✖ Failed to compile.
BobbyTable commented 2 years ago

Arrived at this same place. Was hoping to try this lib with angular but no go :/ Any versions that are known to work? (angular, typescript etc)

ianrapid commented 2 years ago

I was able to compile by installing individual modules, but I haven't been able to make it work.

thegnuu commented 2 years ago

Had the same issue, you can add "skipLibCheck": true to skip checks of invalid d.ts files in your node_modules and project files. Since libraries are often written in js and d.ts files are somehow generated, this option might make sense for you guys...

You can find a more detailed post about skipLibCheck here: https://www.testim.io/blog/typescript-skiplibcheck/

VishnuRaghavan commented 2 years ago

I have got it working so far by updating index.d.ts file under node_modules/@interactjs/types/index.d.ts

Screen Shot 2022-02-15 at 3 36 05 PM

NOTE: I havent tested it properly but compilation seems to be working fine.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.