Skip to content

Commit 3cdcf89

Browse files
authored
chore(test): remove some ts-expect-error (#1037)
1 parent 8c4f602 commit 3cdcf89

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed

test/integration/node-middleware.test.ts

+16-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, beforeAll, afterEach, expect, test, vi } from "vitest";
22
import { createServer } from "node:http";
33
import { readFileSync } from "node:fs";
4+
import type { AddressInfo } from "node:net";
45

56
import { sign } from "@octokit/webhooks-methods";
67

@@ -38,8 +39,7 @@ describe("createNodeMiddleware(webhooks)", () => {
3839

3940
const server = createServer(createNodeMiddleware(webhooks)).listen();
4041

41-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
42-
const { port } = server.address();
42+
const { port } = server.address() as AddressInfo;
4343

4444
const response = await fetch(
4545
`http://localhost:${port}/api/github/webhooks`,
@@ -83,8 +83,7 @@ describe("createNodeMiddleware(webhooks)", () => {
8383
expect(event.id).toBe("123e4567-e89b-12d3-a456-426655440000");
8484
});
8585

86-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
87-
const { port } = server.address();
86+
const { port } = server.address() as AddressInfo;
8887

8988
const response = await fetch(
9089
`http://localhost:${port}/api/github/webhooks`,
@@ -113,8 +112,7 @@ describe("createNodeMiddleware(webhooks)", () => {
113112

114113
const server = createServer(createNodeMiddleware(webhooks)).listen();
115114

116-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
117-
const { port } = server.address();
115+
const { port } = server.address() as AddressInfo;
118116
const response = await fetch(
119117
`http://localhost:${port}/api/github/webhooks`,
120118
{
@@ -144,8 +142,7 @@ describe("createNodeMiddleware(webhooks)", () => {
144142

145143
const server = createServer(createNodeMiddleware(webhooks)).listen();
146144

147-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
148-
const { port } = server.address();
145+
const { port } = server.address() as AddressInfo;
149146
const response = await fetch(
150147
`http://localhost:${port}/api/github/webhooks`,
151148
{
@@ -174,8 +171,7 @@ describe("createNodeMiddleware(webhooks)", () => {
174171

175172
const server = createServer(createNodeMiddleware(webhooks)).listen();
176173

177-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
178-
const { port } = server.address();
174+
const { port } = server.address() as AddressInfo;
179175

180176
const payload = '{"name":"invalid"';
181177

@@ -207,8 +203,7 @@ describe("createNodeMiddleware(webhooks)", () => {
207203

208204
const server = createServer(createNodeMiddleware(webhooks)).listen();
209205

210-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
211-
const { port } = server.address();
206+
const { port } = server.address() as AddressInfo;
212207

213208
const response = await fetch(
214209
`http://localhost:${port}/api/github/webhooks`,
@@ -247,8 +242,7 @@ describe("createNodeMiddleware(webhooks)", () => {
247242
}
248243
}).listen();
249244

250-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
251-
const { port } = server.address();
245+
const { port } = server.address() as AddressInfo;
252246

253247
const response = await fetch(`http://localhost:${port}/foo`, {
254248
method: "PUT",
@@ -274,8 +268,7 @@ describe("createNodeMiddleware(webhooks)", () => {
274268

275269
const server = createServer(createNodeMiddleware(webhooks)).listen();
276270

277-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
278-
const { port } = server.address();
271+
const { port } = server.address() as AddressInfo;
279272

280273
const response = await fetch(
281274
`http://localhost:${port}/api/github/webhooks`,
@@ -311,8 +304,7 @@ describe("createNodeMiddleware(webhooks)", () => {
311304

312305
const server = createServer(createNodeMiddleware(webhooks)).listen();
313306

314-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
315-
const { port } = server.address();
307+
const { port } = server.address() as AddressInfo;
316308

317309
const response = await fetch(
318310
`http://localhost:${port}/api/github/webhooks`,
@@ -345,8 +337,7 @@ describe("createNodeMiddleware(webhooks)", () => {
345337

346338
const server = createServer(createNodeMiddleware(webhooks)).listen();
347339

348-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
349-
const { port } = server.address();
340+
const { port } = server.address() as AddressInfo;
350341

351342
const response = await fetch(
352343
`http://localhost:${port}/api/github/webhooks`,
@@ -384,8 +375,7 @@ describe("createNodeMiddleware(webhooks)", () => {
384375

385376
const server = createServer(createNodeMiddleware(webhooks)).listen();
386377

387-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
388-
const { port } = server.address();
378+
const { port } = server.address() as AddressInfo;
389379

390380
const response = await fetch(
391381
`http://localhost:${port}/api/github/webhooks`,
@@ -420,8 +410,7 @@ describe("createNodeMiddleware(webhooks)", () => {
420410

421411
const server = createServer(createNodeMiddleware(webhooks)).listen();
422412

423-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
424-
const { port } = server.address();
413+
const { port } = server.address() as AddressInfo;
425414

426415
const response = await fetch(
427416
`http://localhost:${port}/api/github/webhooks`,
@@ -582,8 +571,7 @@ describe("createNodeMiddleware(webhooks)", () => {
582571
};
583572
const server = createServer(mockedMiddleware).listen();
584573

585-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
586-
const { port } = server.address();
574+
const { port } = server.address() as AddressInfo;
587575

588576
const response = await fetch(
589577
`http://localhost:${port}/api/github/webhooks`,
@@ -628,8 +616,7 @@ describe("createNodeMiddleware(webhooks)", () => {
628616
const middleware = createNodeMiddleware(webhooks, { log });
629617
const server = createServer(middleware).listen();
630618

631-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
632-
const { port } = server.address();
619+
const { port } = server.address() as AddressInfo;
633620

634621
const response = await fetch(
635622
`http://localhost:${port}/api/github/webhooks`,
@@ -678,8 +665,7 @@ test("request.body is already an Object and has request.rawBody as Buffer (e.g.
678665
expect(event.id).toBe("123e4567-e89b-12d3-a456-426655440000");
679666
});
680667

681-
// @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
682-
const { port } = server.address();
668+
const { port } = server.address() as AddressInfo;
683669

684670
const response = await fetch(`http://localhost:${port}/api/github/webhooks`, {
685671
method: "POST",

0 commit comments

Comments
 (0)