angular - Typescript `super` calling from overridden method -
recently found issue in project, here example code (angular 2.3 context):
export class httpservice extends http { ... request(url: string, requestoptions?: requestoptionsargs, config: = {}) { // method overridden ... return super.request(url, options) // called http.request() } getoptions() { ... super.request(url, options) // called this.request() } } can explain why in 1st case called method super expected, in 2nd case called this (found in debug console)?
super still follows prototypical-inheritance rules. meaning try find request first in httpservice.prototype , if doesn't find there go down prototype chain.
here more information behavior: http://2ality.com/2015/02/es6-classes-final.html#referring-to-super-properties-in-methods
Comments
Post a Comment