mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 14:59:37 +08:00
[node] Narrow down type that can be passed to url.format(). (#16850)
* Narrow down type that can be passed to url.format(). * Add format(URL). * [node] Fix build error. universal-analytics package has invalid tslint.json. * [node] Fix build error. universal-analytics package has invalid version number.
This commit is contained in:
committed by
Mohamed Hegazy
parent
796bb77b68
commit
3f95ea32d7
23
types/node/index.d.ts
vendored
23
types/node/index.d.ts
vendored
@@ -1854,10 +1854,31 @@ declare module "url" {
|
||||
path?: string;
|
||||
}
|
||||
|
||||
export interface UrlObject {
|
||||
protocol?: string;
|
||||
slashes?: boolean;
|
||||
auth?: string;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
port?: string | number;
|
||||
pathname?: string;
|
||||
search?: string;
|
||||
query?: { [key: string]: any; };
|
||||
hash?: string;
|
||||
}
|
||||
|
||||
export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url;
|
||||
export function format(url: Url): string;
|
||||
export function format(URL: URL, options?: URLFormatOptions): string;
|
||||
export function format(urlObject: UrlObject): string;
|
||||
export function resolve(from: string, to: string): string;
|
||||
|
||||
export interface URLFormatOptions {
|
||||
auth?: boolean;
|
||||
fragment?: boolean;
|
||||
search?: boolean;
|
||||
unicode?: boolean;
|
||||
}
|
||||
|
||||
export class URLSearchParams implements Iterable<string[]> {
|
||||
constructor(init?: URLSearchParams | string | { [key: string]: string | string[] } | Iterable<string[]> );
|
||||
append(name: string, value: string): void;
|
||||
|
||||
@@ -415,6 +415,9 @@ namespace url_tests {
|
||||
pathname: 'search',
|
||||
query: { q: "you're a lizard, gary" }
|
||||
});
|
||||
|
||||
const myURL = new url.URL('https://a:b@你好你好?abc#foo');
|
||||
url.format(myURL, { fragment: false, unicode: true, auth: false });
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
15
types/node/v6/index.d.ts
vendored
15
types/node/v6/index.d.ts
vendored
@@ -1801,8 +1801,21 @@ declare module "url" {
|
||||
path?: string;
|
||||
}
|
||||
|
||||
export interface UrlObject {
|
||||
protocol?: string;
|
||||
slashes?: boolean;
|
||||
auth?: string;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
port?: string | number;
|
||||
pathname?: string;
|
||||
search?: string;
|
||||
query?: { [key: string]: any; };
|
||||
hash?: string;
|
||||
}
|
||||
|
||||
export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url;
|
||||
export function format(url: Url): string;
|
||||
export function format(urlObject: UrlObject): string;
|
||||
export function resolve(from: string, to: string): string;
|
||||
}
|
||||
|
||||
|
||||
2
types/universal-analytics/index.d.ts
vendored
2
types/universal-analytics/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for universal-analytics v0.4.13
|
||||
// Type definitions for universal-analytics 0.4
|
||||
// Project: https://github.com/peaksandpies/universal-analytics
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Iker Pérez Brunelli <https://github.com/DarkerTV>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user