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:
Magnus Hiie
2017-03-22 19:43:32 +02:00
parent e74da0e16c
commit e37fc19ad4
3 changed files with 6 additions and 7 deletions
+1 -1
View File
@@ -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;
+4 -6
View File
@@ -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]);
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }