minze icon indicating copy to clipboard operation
minze copied to clipboard

Unable to import Minze default component to an Angular project (TS Error)

Open gnesher opened this issue 3 years ago • 1 comments

Describe the bug

After building the default project I've tried importing the components to a blank Angular project. I can only see the type error in the npm module (after installing the project inside Angular), TypeScript is not complaining in the Minze project itself.

Might be a TypeScript version mismatch?

Reproduction

Build a default Minze project (npm run build) then import it to a local Angular project like so:

` import Minze from 'minze'; import * as Elements from 'minze-angular' ;

Minze.defineAll(Elements);

`

and try to build Angular

System Info

System:
    OS: macOS 12.3.1
    CPU: (8) x64 Apple M1 Pro
    Memory: 90.57 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.3 - ~/.nvm/versions/node/v14.18.3/bin/node
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.3/bin/npm
  Browsers:
    Chrome: 100.0.4896.127
    Safari: 15.4
  npmPackages:
    minze: ^1.0.3 => 1.0.3

Used Package Manager

npm

Logs

`Error: node_modules/minze/dist/module.d.ts:236:5 - error TS2416: Property 'eventListeners' in type 'MinzeElement' is not assignable to the same property in base type 'HTMLElement'.
  Type 'EventListeners | undefined' is not assignable to type '((eventName?: string | undefined) => EventListenerOrEventListenerObject[]) | undefined'.
    Type 'EventListeners' is not assignable to type '(eventName?: string | undefined) => EventListenerOrEventListenerObject[]'.
      Type 'readonly MinzeEvent[]' provides no match for the signature '(eventName?: string | undefined): EventListenerOrEventListenerObject[]'.

236     eventListeners?: EventListeners;
        ~~~~~~~~~~~~~~`

Validations

gnesher avatar Apr 26 '22 06:04 gnesher

Not related to TypeScript versions, seem to be connected to Zone.js that modifies the HTMLElement type and adds an eventListeners property (yay).

Any chance we could rename eventListeners to something else? I realize this is idiotic, but sadly it's going to take years before Angular is finally phased out

gnesher avatar Apr 27 '22 11:04 gnesher