typescript : can't access base class methods from derived class

Viewed 595

I've tried to extend an Openlayers control class to a custom class in typescript . Even after making super() call , I can't access the super class methods ,

import olControl from 'ol/control/control';
@Component({
  selector: 'track-me',
  template: require('./zoomhistory.html'),
  //styles: [require('./map.scss')]
})
  export class ZoomControl extends olControl {
    static parameters = [];
    constructor() {

      let zoomCtrlButton = document.getElementById('trackme');
      super({ element: zoomCtrlButton });   
      var self = this;
      debugger;
      self.setMap(this._map);
    }
  }

it will show property setMap() doesn't exist on type ZoomControl , can't compile then. But when i put debugger and hover on this i can see setMap method from developer console . Is there any workaround for this ?

1 Answers
  • Make sure ‘setMap’ is defined as public method in olControl
  • Try to access to this method as self[“setMap”](this._map)
Related