dzintars / front

Test setup (Don't use!) Dev server URL available while i'm developing.
https://front.oswee.dev
1 stars 1 forks source link

TS2416: Property 'mapEvents' in type 'MainLauncherElement' is not assignable to the same property in base type 'Connectable & LitElement'. #51

Closed dzintars closed 4 years ago

dzintars commented 4 years ago

ERROR in /home/dzintars/code/github.com/dzintars/front/src/ui/containers/main-launcher/component.ts ./src/ui/containers/main-launcher/component.ts [tsl] ERROR in /home/dzintars/code/github.com/dzintars/front/src/ui/containers/main-launcher/component.ts(38,3) TS2416: Property 'mapEvents' in type 'MainLauncherElement' is not assignable to the same property in base type 'Connectable & LitElement'. Type '() => { 'nav-item-click': (e: CustomEvent) => ApplicationActionTypes; 'nav-item-mouseover': (e: CustomEvent) => void; }' is not assignable to type '() => { [key: string]: (event: Event) => Action; }'. Type '{ 'nav-item-click': (e: CustomEvent) => ApplicationActionTypes; 'nav-item-mouseover': (e: CustomEvent) => void; }' is not assignable to type '{ [key: string]: (event: Event) => Action; }'. Property ''nav-item-mouseover'' is incompatible with index signature. Type '(e: CustomEvent) => void' is not assignable to type '(event: Event) => Action'. Type 'void' is not assignable to type 'Action'. ℹ 「wdm」: Failed to compile.

dzintars commented 4 years ago

Caused becuse i tried to console.log 'nav-item-mouseover': (e: CustomEvent<NavItemElementData>) => console.log(e.detail.key). Not sure is it limitation of connect library

dzintars commented 4 years ago

I'm an idiot. mapEvents() is not supposed to be used for general custom events interception. You can intercept custom events in the constructor simply by

  constructor() {
    super()
    this.addEventListener('nav-item-mouseover', this.test)
  }

mapEvents() can call only Redux action creators.