mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* @types/koa-compose: Add more typed compose cases
Right now if you want typesafe compose, you have to compose composes by
2-element arrays. I.e. if you have 4 middlewares you want to compose
together, and you want to do that in a typesafe way, without losing type
information, you have to do it like this:
```ts
import compose from "koa-compose"
const myMiddleware = compose([
firstMiddleware,
compose([
secondMiddleware,
compose([
thirdMiddleware,
fourthMiddleware
])
])
]);
```
It works, but looks clunky it complicated. Would be cool to still have
type-safe way of composing, but with less clunkiness. Like:
```
import compose from "koa-compose"
const myMiddleware = compose([
firstMiddleware,
secondMiddleware,
thirdMiddleware,
fourthMiddleware
]);
```
It's hard to solve that issue for general case, but we could just add
typesafe compose overrides for up to e.g. 8-element arrays. If it's more
than 8 - you still can compose composes. But in general IMHO it will
reduce clunkiness of it.
* @types/koa-compose: Add Anton Astashov to the list of maintainers
|
||
|---|---|---|
| .. | ||
| index.d.ts | ||
| koa-compose-tests.ts | ||
| tsconfig.json | ||
| tslint.json | ||