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:
Ethan Resnick
2016-11-21 04:17:52 -08:00
parent e6e18740a5
commit 1c80f69f6e
2 changed files with 3 additions and 3 deletions

View File

@@ -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;
}
}

View File

@@ -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