From 8fa67cd896588e0f99a0beb2dfba8a5a3e8877a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= <18708370+Flarna@users.noreply.github.com> Date: Mon, 18 Nov 2019 21:45:00 +0100 Subject: [PATCH] [node] ensure compatiblity between http.request and url.parse (#40430) * [node] ensure compatiblity between http.request and url.parse Ensure that output of url.parse() fits into http.request() as indicated at https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback * fix typo Co-Authored-By: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> --- types/node/http.d.ts | 12 ++++++------ types/node/test/http.ts | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/types/node/http.d.ts b/types/node/http.d.ts index ef5f1efccf..65ea677dee 100644 --- a/types/node/http.d.ts +++ b/types/node/http.d.ts @@ -69,18 +69,18 @@ declare module "http" { } interface ClientRequestArgs { - protocol?: string; - host?: string; - hostname?: string; + protocol?: string | null; + host?: string | null; + hostname?: string | null; family?: number; - port?: number | string; + port?: number | string | null; defaultPort?: number | string; localAddress?: string; socketPath?: string; method?: string; - path?: string; + path?: string | null; headers?: OutgoingHttpHeaders; - auth?: string; + auth?: string | null; agent?: Agent | boolean; _defaultAgent?: Agent; timeout?: number; diff --git a/types/node/test/http.ts b/types/node/test/http.ts index e0147fda60..5a39fb385b 100644 --- a/types/node/test/http.ts +++ b/types/node/test/http.ts @@ -139,6 +139,8 @@ import * as net from 'net'; http.request({ agent: false }); http.request({ agent }); http.request({ agent: undefined }); + // ensure compatibility with url.parse() + http.request(url.parse("http://www.example.org/xyz")); } {