mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 06:17:04 +00:00
Merge pull request #10341 from janpieterz/master
Added the .then Promise return for superagent
This commit is contained in:
@@ -279,3 +279,9 @@ request
|
||||
.attach('image', 'path/to/tobi.png')
|
||||
.on('error', (err: any) => {})
|
||||
.end(callback);
|
||||
|
||||
//Promise
|
||||
request
|
||||
.get('/search')
|
||||
.then((response) => {})
|
||||
.catch((error) => {});
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for SuperAgent v1.4.0
|
||||
// Type definitions for SuperAgent v2.0.0
|
||||
// Project: https://github.com/visionmedia/superagent
|
||||
// Definitions by: Alex Varju <https://github.com/varju/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -80,7 +80,7 @@ declare module "superagent" {
|
||||
get(header: string): string;
|
||||
}
|
||||
|
||||
interface Request /* extends NodeJS.WritableStream */ {
|
||||
interface Request extends Promise<Response> /* extends NodeJS.WritableStream */ {
|
||||
abort(): void;
|
||||
accept(type: string): this;
|
||||
attach(field: string, file: string, filename?: string): this;
|
||||
|
||||
+1
-24
@@ -22,7 +22,7 @@ declare module "supertest-as-promised" {
|
||||
interface Response extends supertest.Response {
|
||||
}
|
||||
|
||||
interface Test extends Promise<Response>, supertest.Test, supersgent.Request {
|
||||
interface Test extends supertest.Test, supersgent.Request {
|
||||
toPromise(): PromiseBlurbird<Response>;
|
||||
}
|
||||
|
||||
@@ -33,27 +33,4 @@ declare module "supertest-as-promised" {
|
||||
}
|
||||
export = supertestAsPromised
|
||||
|
||||
// from core-js.d.ts
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
interface Promise<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
|
||||
catch(onrejected?: (reason: any) => void): Promise<T>;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user