i want to access to class function when wxtends that class in typescript .
this is my class BaseController :
"use strict";
import { validationResult } from "express-validator";
import applyBind from 'auto-bind';
export class ValidationResult {
haveError: boolean;
errorMessage: string[];
constructor(haveError: boolean, errorMessage: string[]) { }
}
export default class BaseCotnroller {
constructor() {
applyBind.bind(this);
}
static async ValidationAction(req, res): Promise<ValidationResult> {
const result = await validationResult(req);
if (!result.isEmpty()) {
let errors = result.array();
let message = [];
errors.forEach((element) => {
message.push(element.msg);
});
return new ValidationResult(true, message);
}
return new ValidationResult(false, null);
}
}
and then extends the BaseController :
import BaseCotnroller from './BaseController';
export default class PermissionController extends BaseCotnroller {
constructor() {
super();
}
/*** Create Permission ****/
static async CreatePermission(req, res, next) {
let validationData = await this.ValidationAction(req, res);
if (!validationData.haveError) {
PermissionRepository.CreatePermission(req)
.then(() => {
this.Ok(res);
})
.catch((error) => {
return this.BadRerquest(res, error);
});
} else {
return this.BadRerquest(res, validationData.errorMessage);
}
}
}
but it show me this error :
error TypeError: Cannot read property 'ValidationAction' of undefined at F:\Projects\Nodejs\Travel Budy\src\http\controller\PermissionController.ts:20:45 at Generator.next () at F:\Projects\Nodejs\Travel Budy\src\http\controller\PermissionController.ts:8:71 at new Promise () at __awaiter (F:\Projects\Nodejs\Travel Budy\src\http\controller\PermissionController.ts:4:12) at CreatePermission (F:\Projects\Nodejs\Travel Budy\src\http\controller\PermissionController.ts:24:16) at Layer.handle [as handle_request] (F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\layer.js:95:5) at next (F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\layer.js:95:5) at F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\index.js:281:22 at Function.process_params (F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\index.js:335:12) at next (F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\index.js:275:10) at Function.handle (F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\index.js:174:3) at router (F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\index.js:47:12) at Layer.handle [as handle_request] (F:\Projects\Nodejs\Travel Budy\node_modules\express\lib\router\layer.js:95:5)
now whats the problem ? how can i solve this problem ?