[url-parse] Export URL definition in url-parse (#27125)

* Export URL in url-parse

* Add to definitions by list
This commit is contained in:
Hari Sivaramakrishnan 2018-07-13 13:02:09 -07:00 committed by Ryan Cavanaugh
parent b2b13c6fb0
commit 9b1c19d214
2 changed files with 27 additions and 24 deletions

View File

@ -1,6 +1,7 @@
// Type definitions for url-parse 1.1
// Project: https://github.com/unshiftio/url-parse
// Definitions by: Pavlo Chernenko <https://github.com/ChernenkoPaul>
// Hari Sivaramakrishnan <https://github.com/harisiva>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@ -8,28 +9,30 @@ import URLSearchParams = require("url-search-params");
type UrlQueryParamsParser = (url: string) => string;
declare class URL {
readonly auth: string;
readonly hash: string;
readonly host: string;
readonly hostname: string;
readonly href: string;
readonly origin: string;
readonly password: string;
readonly pathname: string;
readonly port: string;
readonly protocol: string;
query: { [key: string]: string | undefined };
readonly search: string;
set(property: string, value: string | object | number | undefined): URL;
readonly slashes: boolean;
readonly username: string;
readonly searchParams: URLSearchParams;
toString(): string;
declare namespace parse {
interface URL {
readonly auth: string;
readonly hash: string;
readonly host: string;
readonly hostname: string;
readonly href: string;
readonly origin: string;
readonly password: string;
readonly pathname: string;
readonly port: string;
readonly protocol: string;
query: { [key: string]: string | undefined };
readonly search: string;
set(property: string, value: string | object | number | undefined): URL;
readonly slashes: boolean;
readonly username: string;
readonly searchParams: URLSearchParams;
toString(): string;
}
}
type ParseFunctionNodeType = (url: string, parseQueryString?: boolean, slashesDenoteHost?: boolean) => URL;
type ParseFunctionType = (url: string, baseURL?: object | string, parser?: boolean | UrlQueryParamsParser) => URL;
type ParseFunctionNodeType = (url: string, parseQueryString?: boolean, slashesDenoteHost?: boolean) => parse.URL;
type ParseFunctionType = (url: string, baseURL?: object | string, parser?: boolean | UrlQueryParamsParser) => parse.URL;
interface Protocol {
slashes: boolean;

View File

@ -1,10 +1,10 @@
import parse = require("url-parse");
const url1 = new URL("foo/bar", "https://github.com/");
const url2 = parse("https://github.com/foo/bar?baz=true");
const url3 = parse("https://github.com/foo/bar", true, true);
const url4 = parse("foo/bar", "https://github.com/");
const url5 = parse("foo/bar", "https://github.com/", () => "queryParserOverride");
const url2: parse.URL = parse("https://github.com/foo/bar?baz=true");
const url3: parse.URL = parse("https://github.com/foo/bar", true, true);
const url4: parse.URL = parse("foo/bar", "https://github.com/");
const url5: parse.URL = parse("foo/bar", "https://github.com/", () => "queryParserOverride");
url2.hash;
url2.hostname;