Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This expression is not callable. Type 'Number' has no call signatures

Hi I'm new in Typescript, I have an object-type variable in which might be different values from different types or nested object. now my question is that how can I define a model for this object to don't face the example error when call different keys?

For example:

export class Controller {
protected static response(res: Response, statusCode: number = 200, data: any, user: string = '', dev: string = '', code: number = 200, result: string = 'success'){
    res.status(statusCode).send({
        data: data,
        message: {
            user: '',
            dev: ''
        },
        code: 403,
        result: 'Error'
    })
}


 ERROR: res.status ---> This expression is not callable. Type 'Number' has no call signatures
like image 395
Mohammad Avatar asked Feb 29 '20 08:02

Mohammad


1 Answers

I was getting this error as well, and realized I'd just forgotten to import Response. Adding an import line solved the problem for me.

import express, {Request, Response} from 'express';
like image 144
Mark DeLoura Avatar answered Sep 22 '22 08:09

Mark DeLoura