mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
superagent: Fix callback signature
Error can be an error object or null at least (and possibly some other values, like undefined, though those aren’t documented). There was already a test with error being null, but it was passing only because strictNullChecks were off. Now that strictNullChecks are on, this must be changed.
This commit is contained in:
4
superagent/index.d.ts
vendored
4
superagent/index.d.ts
vendored
@@ -49,7 +49,7 @@ declare namespace request {
|
||||
search(url: string, callback?: CallbackHandler): Req;
|
||||
connect(url: string, callback?: CallbackHandler): Req;
|
||||
|
||||
parse(fn: (res: Response, callback: (err: Error, body: any) => void) => void): this;
|
||||
parse(fn: (res: Response, callback: (err: Error | null, body: any) => void) => void): this;
|
||||
saveCookies(res: Response): void;
|
||||
attachCookies(req: Req): void;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ declare namespace request {
|
||||
withCredentials(): this;
|
||||
write(data: string, encoding?: string): this;
|
||||
write(data: Buffer, encoding?: string): this;
|
||||
parse(fn: (res: Response, callback: (err: Error, body: any) => void) => void): this;
|
||||
parse(fn: (res: Response, callback: (err: Error | null, body: any) => void) => void): this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ request
|
||||
request
|
||||
.get('/search')
|
||||
.then((response) => {})
|
||||
.catch((error) => {});
|
||||
.catch((error) => {});
|
||||
// Requesting binary data.
|
||||
// adapted from: https://github.com/visionmedia/superagent/blob/v2.0.0/test/client/request.js#L110
|
||||
request
|
||||
|
||||
Reference in New Issue
Block a user