I have a service (class in TypeScript) app/resources/GeneralResource.ts and other services in the app/resources/ folder. I want to inherit all my resources from GeneralResources .
All files (classes) that go after the GeneralResource.ts file in alphabetical order work fine. But all files (classes) that go to GeneralResource.ts have a runtime error.
Here is an example class:
export class DefectReasonResource extends GeneralResource implements IDefectReasonResource { static $inject = ['$q', '$http', 'baseUrl']; constructor(public $q:ng.IQService, public $http:ng.IHttpService, public baseUrl:string) { super($q, $http); }
This class compiles fine:
var app; (function (app) { var common; (function (common) { var DefectReasonResource = (function (_super) { __extends(DefectReasonResource, _super); function DefectReasonResource($q, $http, baseUrl) { _super.call(this, $q, $http); this.$q = $q; this.$http = $http; this.baseUrl = baseUrl; } DefectReasonResource.$inject = ['$q', '$http', 'baseUrl']; return DefectReasonResource; })(common.GeneralResource); common.DefectReasonResource = DefectReasonResource; angular.module('myApp').service('defectReasonResource', DefectReasonResource); })(common = app.common || (app.common = {})); })(app || (app = {}));
But when I open the file, I have an error in the browser:
Uncaught TypeError: Cannot read the 'prototype' property from undefined
I just want to emphasize that I do not have this problem with all classes declared after GeneralResource .
I think it's best to remove inheritance and add GeneralResource to all my services. But I wonder if the inheritance solution can be fixed?
demas source share