DefinitelyTyped / DefinitelyTyped

The repository for high quality TypeScript type definitions.
Other
48.54k stars 30.15k forks source link

status interface #63387

Open DM-UOC opened 1 year ago

DM-UOC commented 1 year ago

Status interface give a warning althoug a number is declared. Bisides, gia a message: "Property status does not exist on type Response<string, any>"

Semigradsky commented 1 year ago

@DM-UOC What the package?

ZeroCho commented 1 year ago

@Semigradsky @types/express-serve-static-core

import {
  ExceptionFilter,
  Catch,
  ArgumentsHost,
  HttpException,
} from '@nestjs/common';
import { Request, Response } from 'express';

@Catch(HttpException)
export class HttpExceptionFilter implements ExceptionFilter {
  catch(exception: HttpException, host: ArgumentsHost) {
    const ctx = host.switchToHttp();
    const response = ctx.getResponse<Response>();
    const httpStatus = exception.getStatus();
    response.status(httpStatus).json({});
  }
}

image image

Semigradsky commented 1 year ago

@ZeroCho what the version of @types/express-serve-static-core you have?