mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Fix koa-compose typings
This changes ComposedMiddleware take next as a parameterless async function. Also, add tslint.json and fix lint errors.
This commit is contained in:
Vendored
+1
-1
@@ -8,7 +8,7 @@ declare function compose<T>(middleware: Array<compose.Middleware<T>>): compose.C
|
||||
|
||||
declare namespace compose {
|
||||
type Middleware<T> = (context: T, next: () => Promise<any>) => any;
|
||||
type ComposedMiddleware<T> = (context: T, next?: Middleware<T>) => Promise<void>;
|
||||
type ComposedMiddleware<T> = (context: T, next?: () => Promise<any>) => Promise<void>;
|
||||
}
|
||||
|
||||
export = compose;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
import compose = require('koa-compose');
|
||||
|
||||
var fn1: compose.Middleware<any> = function(context: any, next: () => Promise<void>): Promise<any> {
|
||||
return Promise
|
||||
var fn1: compose.Middleware<any> = (context: any, next: () => Promise<void>): Promise<any> =>
|
||||
Promise
|
||||
.resolve(console.log('in fn1'))
|
||||
.then(() => next());
|
||||
};
|
||||
|
||||
var fn2: compose.Middleware<any> = function(context: any, next: () => Promise<void>): Promise<any> {
|
||||
return Promise
|
||||
var fn2: compose.Middleware<any> = (context: any, next: () => Promise<void>): Promise<any> =>
|
||||
Promise
|
||||
.resolve(console.log('in fn2'))
|
||||
.then(() => next());
|
||||
};
|
||||
|
||||
|
||||
var fn = compose([fn1, fn2]);
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user