mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Fix implicit any issues
This commit is contained in:
@@ -37,7 +37,6 @@ import fs = require('fs');
|
||||
import http = require('http');
|
||||
var request = rp;
|
||||
|
||||
//The following examples from https://github.com/request/request
|
||||
request('http://www.google.com', function (error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
console.log(body); // Show the HTML for the Google homepage.
|
||||
@@ -52,7 +51,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img
|
||||
|
||||
request
|
||||
.get('http://google.com/img.png')
|
||||
.on('response', function(response) {
|
||||
.on('response', function(response: any) {
|
||||
console.log(response.statusCode); // 200
|
||||
console.log(response.headers['content-type']); // 'image/png'
|
||||
})
|
||||
@@ -60,7 +59,7 @@ request
|
||||
|
||||
request
|
||||
.get('http://mysite.com/doodle.png')
|
||||
.on('error', function(err) {
|
||||
.on('error', function(err: any) {
|
||||
console.log(err);
|
||||
})
|
||||
.pipe(fs.createWriteStream('doodle.png'));
|
||||
@@ -212,7 +211,7 @@ options = {
|
||||
}
|
||||
};
|
||||
|
||||
function callback(error, response, body) {
|
||||
function callback(error: any, response: http.IncomingMessage, body: string) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
var info = JSON.parse(body);
|
||||
console.log(info.stargazers_count + " Stars");
|
||||
@@ -248,7 +247,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
|
||||
// step 3
|
||||
// after the user is redirected back to your server
|
||||
var auth_data = qs.parse(body)
|
||||
var auth_data: any = qs.parse(body)
|
||||
, oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
@@ -260,20 +259,19 @@ request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
;
|
||||
request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
// ready to make signed requests on behalf of the user
|
||||
var perm_data = qs.parse(body)
|
||||
, oauth =
|
||||
var perm_data: any = qs.parse(body);
|
||||
var oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
, token: perm_data.oauth_token
|
||||
, token_secret: perm_data.oauth_token_secret
|
||||
}
|
||||
, url = 'https://api.twitter.com/1.1/users/show.json'
|
||||
, qs =
|
||||
{ screen_name: perm_data.screen_name
|
||||
, user_id: perm_data.user_id
|
||||
}
|
||||
;
|
||||
request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) {
|
||||
};
|
||||
var url = 'https://api.twitter.com/1.1/users/show.json';
|
||||
var query = {
|
||||
screen_name: perm_data.screen_name,
|
||||
user_id: perm_data.user_id
|
||||
};
|
||||
request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) {
|
||||
console.log(user);
|
||||
});
|
||||
});
|
||||
@@ -418,13 +416,13 @@ request(
|
||||
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'))
|
||||
console.log('the decoded data is: ' + body)
|
||||
}
|
||||
).on('data', function(data) {
|
||||
).on('data', function(data: any) {
|
||||
// decompressed data as it is received
|
||||
console.log('decoded chunk: ' + data)
|
||||
})
|
||||
.on('response', function(response) {
|
||||
.on('response', function(response: http.IncomingMessage) {
|
||||
// unmodified http.IncomingMessage object
|
||||
response.on('data', function(data) {
|
||||
response.on('data', function(data: any[]) {
|
||||
// compressed data as it is received
|
||||
console.log('received ' + data.length + ' bytes of compressed data')
|
||||
})
|
||||
|
||||
+16
-17
@@ -212,7 +212,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img
|
||||
|
||||
request
|
||||
.get('http://google.com/img.png')
|
||||
.on('response', function(response) {
|
||||
.on('response', function(response: any) {
|
||||
console.log(response.statusCode); // 200
|
||||
console.log(response.headers['content-type']); // 'image/png'
|
||||
})
|
||||
@@ -220,7 +220,7 @@ request
|
||||
|
||||
request
|
||||
.get('http://mysite.com/doodle.png')
|
||||
.on('error', function(err) {
|
||||
.on('error', function(err: any) {
|
||||
console.log(err);
|
||||
})
|
||||
.pipe(fs.createWriteStream('doodle.png'));
|
||||
@@ -370,7 +370,7 @@ options = {
|
||||
}
|
||||
};
|
||||
|
||||
function callback(error, response, body) {
|
||||
function callback(error: any, response: http.IncomingMessage, body: string) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
var info = JSON.parse(body);
|
||||
console.log(info.stargazers_count + " Stars");
|
||||
@@ -406,7 +406,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
|
||||
// step 3
|
||||
// after the user is redirected back to your server
|
||||
var auth_data = qs.parse(body)
|
||||
var auth_data: any = qs.parse(body)
|
||||
, oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
@@ -418,20 +418,19 @@ request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
;
|
||||
request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
// ready to make signed requests on behalf of the user
|
||||
var perm_data = qs.parse(body)
|
||||
, oauth =
|
||||
var perm_data: any = qs.parse(body);
|
||||
var oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
, token: perm_data.oauth_token
|
||||
, token_secret: perm_data.oauth_token_secret
|
||||
}
|
||||
, url = 'https://api.twitter.com/1.1/users/show.json'
|
||||
, qs =
|
||||
{ screen_name: perm_data.screen_name
|
||||
, user_id: perm_data.user_id
|
||||
}
|
||||
;
|
||||
request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) {
|
||||
};
|
||||
var url = 'https://api.twitter.com/1.1/users/show.json';
|
||||
var query = {
|
||||
screen_name: perm_data.screen_name,
|
||||
user_id: perm_data.user_id
|
||||
};
|
||||
request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) {
|
||||
console.log(user);
|
||||
});
|
||||
});
|
||||
@@ -576,13 +575,13 @@ request(
|
||||
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'))
|
||||
console.log('the decoded data is: ' + body)
|
||||
}
|
||||
).on('data', function(data) {
|
||||
).on('data', function(data: any) {
|
||||
// decompressed data as it is received
|
||||
console.log('decoded chunk: ' + data)
|
||||
})
|
||||
.on('response', function(response) {
|
||||
.on('response', function(response: http.IncomingMessage) {
|
||||
// unmodified http.IncomingMessage object
|
||||
response.on('data', function(data) {
|
||||
response.on('data', function(data: any[]) {
|
||||
// compressed data as it is received
|
||||
console.log('received ' + data.length + ' bytes of compressed data')
|
||||
})
|
||||
|
||||
Vendored
+25
-24
@@ -18,36 +18,33 @@ declare module 'request' {
|
||||
namespace request {
|
||||
export interface RequestAPI<TRequest extends Request> {
|
||||
defaults(options: Options): RequestAPI<TRequest>;
|
||||
(uri: string,
|
||||
options?: Options,
|
||||
callback?: (error: any, response: http.IncomingMessage, body: any) => void)
|
||||
: TRequest;
|
||||
(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
(options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
(uri: string, options?: Options, callback?: RequestCallback): TRequest;
|
||||
(uri: string, callback?: RequestCallback): TRequest;
|
||||
(options?: Options, callback?: RequestCallback): TRequest;
|
||||
|
||||
get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
get(uri: string, options?: Options, callback?: RequestCallback): TRequest;
|
||||
get(uri: string, callback?: RequestCallback): TRequest;
|
||||
get(options: Options, callback?: RequestCallback): TRequest;
|
||||
|
||||
post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
post(uri: string, options?: Options, callback?: RequestCallback): TRequest;
|
||||
post(uri: string, callback?: RequestCallback): TRequest;
|
||||
post(options: Options, callback?: RequestCallback): TRequest;
|
||||
|
||||
put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
put(uri: string, options?: Options, callback?: RequestCallback): TRequest;
|
||||
put(uri: string, callback?: RequestCallback): TRequest;
|
||||
put(options: Options, callback?: RequestCallback): TRequest;
|
||||
|
||||
head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
head(uri: string, options?: Options, callback?: RequestCallback): TRequest;
|
||||
head(uri: string, callback?: RequestCallback): TRequest;
|
||||
head(options: Options, callback?: RequestCallback): TRequest;
|
||||
|
||||
patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
patch(uri: string, options?: Options, callback?: RequestCallback): TRequest;
|
||||
patch(uri: string, callback?: RequestCallback): TRequest;
|
||||
patch(options: Options, callback?: RequestCallback): TRequest;
|
||||
|
||||
del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest;
|
||||
del(uri: string, options?: Options, callback?: RequestCallback): TRequest;
|
||||
del(uri: string, callback?: RequestCallback): TRequest;
|
||||
del(options: Options, callback?: RequestCallback): TRequest;
|
||||
|
||||
forever(agentOptions: any, optionsArg: any): TRequest;
|
||||
jar(): CookieJar;
|
||||
@@ -97,6 +94,10 @@ declare module 'request' {
|
||||
har?: HttpArchiveRequest;
|
||||
}
|
||||
|
||||
export interface RequestCallback {
|
||||
(error: any, response: http.IncomingMessage, body: any): void;
|
||||
}
|
||||
|
||||
export interface HttpArchiveRequest {
|
||||
url?: string;
|
||||
method?: string;
|
||||
|
||||
Reference in New Issue
Block a user