diff --git a/packages/platform-express/adapters/express-adapter.ts b/packages/platform-express/adapters/express-adapter.ts index 20726abd0ed..718a3f4fd13 100644 --- a/packages/platform-express/adapters/express-adapter.ts +++ b/packages/platform-express/adapters/express-adapter.ts @@ -1,3 +1,4 @@ +import type { Server } from 'net'; import { InternalServerErrorException, Logger, @@ -127,9 +128,13 @@ export class ExpressAdapter extends AbstractHttpAdapter { return response.set(name, value); } - public listen(port: string | number, callback?: () => void); - public listen(port: string | number, hostname: string, callback?: () => void); - public listen(port: any, ...args: any[]) { + public listen(port: string | number, callback?: () => void): Server; + public listen( + port: string | number, + hostname: string, + callback?: () => void, + ): Server; + public listen(port: any, ...args: any[]): Server { return this.httpServer.listen(port, ...args); } diff --git a/packages/platform-express/interfaces/nest-express-application.interface.ts b/packages/platform-express/interfaces/nest-express-application.interface.ts index 0b93c1dbfda..75da409d29c 100644 --- a/packages/platform-express/interfaces/nest-express-application.interface.ts +++ b/packages/platform-express/interfaces/nest-express-application.interface.ts @@ -1,3 +1,4 @@ +import { Server } from 'net'; import { INestApplication } from '@nestjs/common'; import { ServeStaticOptions } from './serve-static-options.interface'; @@ -9,6 +10,21 @@ import { ServeStaticOptions } from './serve-static-options.interface'; * @publicApi */ export interface NestExpressApplication extends INestApplication { + /** + * Starts the application. + * + * @param {number|string} port + * @param {string} [hostname] + * @param {Function} [callback] Optional callback + * @returns {Promise} A Promise that, when resolved, is a reference to the underlying HttpServer. + */ + listen(port: number | string, callback?: () => void): Promise; + listen( + port: number | string, + hostname: string, + callback?: () => void, + ): Promise; + /** * A wrapper function around native `express.set()` method. *