0

I'm having problems using the on in typescript, I need to use event.context but it's from ol.render.Event but I only can receive ol.events.Event

this.imagery.on('precompose', function(event){})

To get around this I tried this

this.imagery.on('precompose', function(event: ol.render.Event){})

But I get this error

ERROR in src/app/app.component.ts(141,35): error TS2345: Argument of 
type '(event: Event) => void' is not assignable to parameter of type 
'EventsListenerFunctionType'.
  Type '(event: Event) => void' is not assignable to type '(evt: Event) => boolean'.
Types of parameters 'event' and 'evt' are incompatible.
  Type 'ol.events.Event' is not assignable to type 'ol.render.Event'.
    Property 'vectorContext' is missing in type 'Event'.
  • If you declare `function(event) { ... }` and then cast the `event` to `ol.render.Event` inside the function, does it have all the members of `ol.render.Event`? If so, the type declaration for `this.imagery.on` needs to be updated. I can help with this if you can confirm the set of event types that receive `ol.render.Event`. – Matt McCutchen Aug 19 '18 at 23:40
  • The error messages had disapeared, thanks men !!! – Julio Negri Mirandola Aug 21 '18 at 17:01

0 Answers0