diff --git a/types/node/index.d.ts b/types/node/index.d.ts index f768f0aae9..d6bc8695ef 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Node.js 10.7.x +// Type definitions for Node.js 10.9.x // Project: http://nodejs.org/ // Definitions by: Microsoft TypeScript // DefinitelyTyped @@ -186,11 +186,11 @@ interface String { trimRight(): string; } -/************************************************ -* * -* GLOBAL * -* * -************************************************/ +/*-----------------------------------------------* + * * + * GLOBAL * + * * + ------------------------------------------------*/ declare var process: NodeJS.Process; declare var global: NodeJS.Global; declare var console: Console; @@ -1289,7 +1289,9 @@ declare module "http" { // create interface RequestOptions would make the naming more clear to developers export interface RequestOptions extends ClientRequestArgs { } export function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; + export function request(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; export function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; + export function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; export var globalAgent: Agent; } @@ -1891,7 +1893,9 @@ declare module "https" { export function createServer(options: ServerOptions, requestListener?: (req: http.IncomingMessage, res: http.ServerResponse) => void): Server; export function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + export function request(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; export function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + export function get(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; export var globalAgent: Agent; } diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index b4681b1d57..266dc5d97e 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -1708,7 +1708,25 @@ namespace http_tests { } { + http.get('http://www.example.com/xyz'); http.request('http://www.example.com/xyz'); + + http.get('http://www.example.com/xyz', (res: http.IncomingMessage): void => {}); + http.request('http://www.example.com/xyz', (res: http.IncomingMessage): void => {}); + + http.get(new url.URL('http://www.example.com/xyz')); + http.request(new url.URL('http://www.example.com/xyz')); + + http.get(new url.URL('http://www.example.com/xyz'), (res: http.IncomingMessage): void => {}); + http.request(new url.URL('http://www.example.com/xyz'), (res: http.IncomingMessage): void => {}); + + const opts: http.RequestOptions = { + path: '"/some/path' + }; + http.get(new url.URL('http://www.example.com'), opts); + http.request(new url.URL('http://www.example.com'), opts); + http.get(new url.URL('http://www.example.com/xyz'), opts, (res: http.IncomingMessage): void => {}); + http.request(new url.URL('http://www.example.com/xyz'), opts, (res: http.IncomingMessage): void => {}); } { @@ -1770,8 +1788,26 @@ namespace https_tests { agent: undefined }); + https.get('http://www.example.com/xyz'); https.request('http://www.example.com/xyz'); + https.get('http://www.example.com/xyz', (res: http.IncomingMessage): void => {}); + https.request('http://www.example.com/xyz', (res: http.IncomingMessage): void => {}); + + https.get(new url.URL('http://www.example.com/xyz')); + https.request(new url.URL('http://www.example.com/xyz')); + + https.get(new url.URL('http://www.example.com/xyz'), (res: http.IncomingMessage): void => {}); + https.request(new url.URL('http://www.example.com/xyz'), (res: http.IncomingMessage): void => {}); + + const opts: https.RequestOptions = { + path: '/some/path' + }; + https.get(new url.URL('http://www.example.com'), opts); + https.request(new url.URL('http://www.example.com'), opts); + https.get(new url.URL('http://www.example.com/xyz'), opts, (res: http.IncomingMessage): void => {}); + https.request(new url.URL('http://www.example.com/xyz'), opts, (res: http.IncomingMessage): void => {}); + https.globalAgent.options.ca = []; {