Node: URL: correct format/parse parameter types (#40118)

* Node: URL: correct format/parse parameter types

* Fix dependencies

* Fix dependencies

* Revert href change

* Update types/node/url.d.ts

Co-Authored-By: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
This commit is contained in:
Oliver Joseph Ash 2019-11-15 19:38:53 +00:00 committed by Pranav Senthilnathan
parent 862d091f93
commit a3ef14ec54
3 changed files with 29 additions and 20 deletions

View File

@ -3,6 +3,7 @@
// Definitions by: mrmlnc <https://github.com/mrmlnc>
// steprescott <https://github.com/steprescott>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="node"/>
@ -10,7 +11,7 @@ import { Agent } from 'http';
import { Url } from 'url';
declare class HttpProxyAgent extends Agent {
constructor(options: string | Url);
constructor(options: string | Partial<Url>);
proxy: Url;
secureProxy: boolean;

View File

@ -5,6 +5,7 @@
// Daniel Schmidt <https://github.com/DanielMSchmidt>
// Jordan Abreu <https://github.com/jabreu610>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="node" />
@ -15,7 +16,7 @@ import * as events from "events";
import * as url from "url";
import * as stream from "stream";
type ProxyTargetUrl = string | url.Url;
type ProxyTargetUrl = string | Partial<url.Url>;
type ErrorCallback = (
err: Error,

43
types/node/url.d.ts vendored
View File

@ -1,29 +1,36 @@
declare module "url" {
import { ParsedUrlQuery, ParsedUrlQueryInput } from 'querystring';
interface UrlObjectCommon {
auth?: string;
hash?: string;
host?: string;
hostname?: string;
href?: string;
path?: string;
pathname?: string;
protocol?: string;
search?: string;
slashes?: boolean;
}
// Input to `url.format`
interface UrlObject extends UrlObjectCommon {
port?: string | number;
interface UrlObject {
auth?: string | null;
hash?: string | null;
host?: string | null;
hostname?: string | null;
href?: string | null;
path?: string | null;
pathname?: string | null;
protocol?: string | null;
search?: string | null;
slashes?: boolean | null;
port?: string | number | null;
query?: string | null | ParsedUrlQueryInput;
}
// Output of `url.parse`
interface Url extends UrlObjectCommon {
port?: string;
query?: string | null | ParsedUrlQuery;
interface Url {
auth: string | null;
hash: string | null;
host: string | null;
hostname: string | null;
href: string;
path: string | null;
pathname: string | null;
protocol: string | null;
search: string | null;
slashes: boolean | null;
port: string | null;
query: string | null | ParsedUrlQuery;
}
interface UrlWithParsedQuery extends Url {