mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #28565 from pietu/master
Reorder function overloads to allow typescript compiler to match variant with function as an argument
This commit is contained in:
Vendored
+2
-1
@@ -1,6 +1,7 @@
|
||||
// Type definitions for SuperTest v2.0.1
|
||||
// Project: https://github.com/visionmedia/supertest
|
||||
// Definitions by: Alex Varju <https://github.com/varju>
|
||||
// Petteri Parkkila <https://github.com/pietu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -23,12 +24,12 @@ declare namespace supertest {
|
||||
serverAddress(app: any, path: string): string;
|
||||
expect(status: number, callback?: CallbackHandler): this;
|
||||
expect(status: number, body: any, callback?: CallbackHandler): this;
|
||||
expect(checker: (res: Response) => any): this;
|
||||
expect(body: string, callback?: CallbackHandler): this;
|
||||
expect(body: RegExp, callback?: CallbackHandler): this;
|
||||
expect(body: Object, callback?: CallbackHandler): this;
|
||||
expect(field: string, val: string, callback?: CallbackHandler): this;
|
||||
expect(field: string, val: RegExp, callback?: CallbackHandler): this;
|
||||
expect(checker: (res: Response) => any): this;
|
||||
end(callback?: CallbackHandler): this;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,17 @@ function hasPreviousAndNextKeys(res: supertest.Response) {
|
||||
if (!('prev' in res.body)) throw new Error("missing prev key");
|
||||
}
|
||||
|
||||
// functional expect without response type
|
||||
(request
|
||||
.get('/') as supertest.Test)
|
||||
.expect(res => {
|
||||
if (!('next' in res.body)) return "missing next key";
|
||||
if (!('prev' in res.body)) throw new Error("missing prev key");
|
||||
})
|
||||
.end((err: any, res: supertest.Response) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
// object expect
|
||||
(request
|
||||
.get('/') as supertest.Test)
|
||||
|
||||
Reference in New Issue
Block a user