From fb93c75e47befe2ef44cecfa45775a3d9b50042d Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Tue, 17 Oct 2017 08:35:55 -0700 Subject: [PATCH] Fix type of createPushResponse() in node http2. (#20510) * Fix type of createPushResponse() in node http2. From https://github.com/nodejs/node/blob/master/lib/internal/http2/compat.js#L628: `callback` is required to be a function. And its second argument is an `Http2ServerResponse`. * `err` is nullable. * delete redundant tests that have partial arguments --- types/node/index.d.ts | 2 +- types/node/node-tests.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 6455482803..2f9834e411 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -6616,7 +6616,7 @@ declare module "http2" { writeContinue(): void; writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void; writeHead(statusCode: number, statusMessage?: string, headers?: OutgoingHttpHeaders): void; - createPushResponse(headers: OutgoingHttpHeaders, callback?: (err: Error) => void): void; + createPushResponse(headers: OutgoingHttpHeaders, callback: (err: Error | null, res: Http2ServerResponse) => void): void; addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 68ce6f5a18..5929a0c08a 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -3353,8 +3353,7 @@ namespace http2_tests { let headersSent: boolean = response.headersSent; response.setTimeout(0, () => {}); - response.createPushResponse(outgoingHeaders); - response.createPushResponse(outgoingHeaders, (err: Error) => {}); + response.createPushResponse(outgoingHeaders, (err: Error | null, res: http2.Http2ServerResponse) => {}); response.writeContinue(); response.writeHead(200);