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
This commit is contained in:
Jinwoo Lee
2017-10-17 08:35:55 -07:00
committed by Andy
parent a531f8c43d
commit fb93c75e47
2 changed files with 2 additions and 3 deletions

View File

@@ -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;

View File

@@ -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);