Files
DefinitelyTyped/types
Anton Astashov 4e4f50a2fc @types/koa-compose: Add more typed compose cases (#35298)
* @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
2019-05-22 09:13:50 -07:00
..
2019-05-02 20:04:14 -07:00
2019-05-15 09:00:07 -07:00
2019-05-03 09:18:43 -07:00
2019-05-01 10:37:09 -07:00
2019-05-03 15:57:44 -07:00
2019-04-30 09:00:07 -07:00
2019-05-13 09:42:58 -07:00
2019-05-01 16:00:02 -07:00
2019-05-13 16:04:17 -07:00
2019-05-13 16:03:34 -07:00
2019-05-03 09:18:43 -07:00
2019-05-06 12:39:17 -07:00
2019-05-14 13:19:07 -07:00
2019-05-14 13:18:44 -07:00
2019-04-30 09:00:07 -07:00
2019-05-02 20:02:55 -07:00
2019-05-03 14:45:32 -07:00
2019-05-13 16:01:01 -07:00
2019-05-14 14:48:17 -07:00
2019-05-20 14:10:36 -07:00
2019-05-20 10:15:50 -07:00
2019-05-14 14:44:09 -07:00
2019-04-28 23:58:52 -07:00