From 117d429754f3f0a52ae903c3203e0a703022f488 Mon Sep 17 00:00:00 2001 From: Marcin Porebski Date: Fri, 27 Nov 2015 13:53:54 +0100 Subject: [PATCH] Wreck 7.0.0 typings - fixes --- wreck/wreck-tests.ts | 10 ++++------ wreck/wreck.d.ts | 22 +++++++++------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/wreck/wreck-tests.ts b/wreck/wreck-tests.ts index b1e8b0d0b..6e7abab0e 100644 --- a/wreck/wreck-tests.ts +++ b/wreck/wreck-tests.ts @@ -2,7 +2,7 @@ import Wreck = require('wreck'); -Wreck.get('https://google.com/', function (err, res, payload) { +Wreck.get('https://google.com/', {}, function (err: any, res: any, payload: any) { /* do stuff */ }); @@ -23,17 +23,15 @@ var wreckWithTimeout = wreck.defaults({ // all attributes are optional var options = { maxBytes: 1048576, // 1 MB, default: unlimited - rejectUnauthorized: true, - downstreamRes: null, - agent: null, // Node Core http.Agent + rejectUnauthorized: true }; -var optionalCallback = function (err, res) { +var optionalCallback = function (err: any, res: any) { /* handle err if it exists, in which case res will be undefined */ // buffer the response stream - Wreck.read(res, null, function (err, body) { + Wreck.read(res, null, function (err: any, body: any) { /* do stuff */ }); }; diff --git a/wreck/wreck.d.ts b/wreck/wreck.d.ts index 7198de2bb..135b2f4f2 100644 --- a/wreck/wreck.d.ts +++ b/wreck/wreck.d.ts @@ -5,7 +5,7 @@ /// -declare module Wreck +declare module "wreck" { import http = require('http'); import stream = require('stream'); @@ -15,17 +15,17 @@ declare module Wreck { defaults: (options: any) => IWreckObject; - request: (method: string, uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage) => void = null) => http.ClientRequest; + request: (method: string, uri: string, options: any, callback?: (err: any, response: http.IncomingMessage) => void) => http.ClientRequest; read: (response: http.IncomingMessage, options: any, callback: (err: any, payload: any) => void) => void; - get: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest; - post: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest; - patch: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest; - put: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest; - delete: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest; + get: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; + post: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; + patch: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; + put: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; + delete: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; - toReadableStream: (payload: any, encoding: string = null) => stream.Readable; + toReadableStream: (payload: any, encoding?: string) => stream.Readable; parseCacheControl: (field: string) => any; @@ -35,11 +35,7 @@ declare module Wreck }; } -} - -declare module "wreck" -{ - var wreck: Wreck.IWreckObject; + var wreck: IWreckObject; export = wreck; }