Skip to content

Commit 05f7f36

Browse files
authored
🤖 Merge PR DefinitelyTyped#72237 [supertest] Updated type definitions for supertest by @slifty
1 parent dc68346 commit 05f7f36

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

‎types/supertest/supertest-tests.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// Ensure our types support promise-based servers
2+
/* eslint @typescript-eslint/no-misused-promises: "error" */
13
import supertest = require("supertest");
24
import express = require("express");
35

46
import { Server as HttpServer } from "http";
5-
import { Http2SecureServer, Http2Server } from "http2";
7+
import type { Http2SecureServer, Http2Server, Http2ServerRequest, Http2ServerResponse } from "http2";
68
import { Server as HttpsServer } from "https";
79

810
const app = express();
@@ -14,6 +16,7 @@ supertest({} as HttpServer).get("/user").expect(200);
1416
supertest({} as HttpsServer).get("/user").expect(200);
1517
supertest({} as Http2Server).get("/user").expect(200);
1618
supertest({} as Http2SecureServer).get("/user").expect(200);
19+
supertest({} as (request: Http2ServerRequest, response: Http2ServerResponse) => Promise<void>).get("/user").expect(200);
1720

1821
request.get("/user")
1922
.set("Accept", "*/*")

‎types/supertest/types.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Server } from "net";
77
export type App =
88
| Server
99
| RequestListener<typeof IncomingMessage, typeof ServerResponse>
10-
| ((request: Http2ServerRequest, response: Http2ServerResponse) => void)
10+
| ((request: Http2ServerRequest, response: Http2ServerResponse) => void | Promise<void>)
1111
| string;
1212

1313
export interface AgentOptions extends SAgentOptions {

0 commit comments

Comments
 (0)