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.19k stars 782 forks source link

Incompatible with Angular (v17) #1028

Closed msrumon closed 3 months ago

msrumon commented 6 months ago

While integrating this library with Angular, it throws a bunch of TS errors:

✘ [ERROR] TS2428: All declarations of 'BaseEvent' must have identical type parameters. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:324:17:
      324 │     export class BaseEvent<T extends ActionName | null = never> {
          ╵                  ~~~~~~~~~

✘ [ERROR] TS2428: All declarations of 'BaseEvent' must have identical type parameters. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:343:21:
      343 │     export interface BaseEvent<T extends ActionName> {
          ╵                      ~~~~~~~~~

✘ [ERROR] TS2344: Type '"interactable" | "element" | "prepared" | "pointerIsDown" | "pointerWasMoved" | "_proxy" | "start" | "move" | "end" | "stop" | "interacting" | "offsetBy"' does not satisfy the constraint 'keyof Interaction<T>'.
  Type '"_proxy"' is not assignable to type 'keyof Interaction<T>'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:712:93:
      712 │ ...ction<T>, keyof typeof _ProxyValues | keyof typeof _ProxyMetho...
          ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] TS2339: Property 'fire' does not exist on type 'Scope'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:727:29:
      727 │             scopeFire: Scope['fire'];
          ╵                              ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:915:18:
      915 │     import type { Plugin } from "@interactjs/core/scope";
          ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:977:25:
      977 │     import type { Scope, Plugin } from "@interactjs/core/scope";
          ╵                          ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:1091:18:
      1091 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:1193:18:
      1193 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:1360:18:
      1360 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:1435:18:
      1435 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:1562:18:
      1562 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:1746:25:
      1746 │     import type { Scope, Plugin } from "@interactjs/core/scope";
           ╵                          ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:1821:18:
      1821 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:1854:18:
      1854 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:1966:18:
      1966 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:2170:18:
      2170 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:2212:18:
      2212 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:2234:30:
      2234 │     import type { SignalArgs, Plugin } from "@interactjs/core/sc...
           ╵                               ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:2435:18:
      2435 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:2932:18:
      2932 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:2974:18:
      2974 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:3045:18:
      3045 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:3066:18:
      3066 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:3077:18:
      3077 │     import type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:3087:25:
      3087 │     import type { Scope, Plugin } from "@interactjs/core/scope";
           ╵                          ~~~~~~

✘ [ERROR] TS2305: Module '"@interactjs/core/scope"' has no exported member 'Plugin'. [plugin angular-compiler]

    node_modules/@interactjs/types/index.d.ts:3200:18:
      3200 │     export type { Plugin } from "@interactjs/core/scope";
           ╵                   ~~~~~~

Demo

Adding "skipLibCheck":false didn't help.

Related: #949

Tyler-V commented 6 months ago

Noticed this as well,

Adding "skipLibCheck": true, does bypass the error though @msrumon

Use import interact from 'interactjs';

Delagen commented 5 months ago

@msrumon try importing via

const interactjs = require('interactjs');

Seem this library missing some ESM compatibility

As for me library compiled without warnings and disabled skipLibCheck

taye commented 3 months ago

If you have an ESM project, you should use the @interactjs/interactjs package which provides unbundled modules instead of the bundled interactjs package.