Skip to content

Commit 74219ca

Browse files
committed
Better typing
1 parent 8950059 commit 74219ca

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

packages/api/src/middleware/private/templateMiddleware.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { warnOnce } from 'botframework-webchat-core';
22
import { createChainOfResponsibility, type ComponentMiddleware } from 'react-chain-of-responsibility';
3-
import { type EmptyObject } from 'type-fest';
43
import { array, function_, safeParse, type InferOutput } from 'valibot';
54

65
type MiddlewareWithInit<M extends ComponentMiddleware<any, any, any>, I> = (init: I) => ReturnType<M> | false;
@@ -15,8 +14,8 @@ const EMPTY_ARRAY = Object.freeze([]);
1514

1615
// Following @types/react to use {} for props.
1716
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
18-
function templateMiddleware<Request = any, Props extends {} = EmptyObject>(name: string) {
19-
type Middleware = ComponentMiddleware<Request, Props>;
17+
function templateMiddleware<Request, Props extends {}>(name: string) {
18+
type Middleware = ComponentMiddleware<Request, Props, string>;
2019

2120
const createMiddleware = (enhancer: ReturnType<Middleware>): Middleware => {
2221
const factory = init => init === name && enhancer;
@@ -31,7 +30,7 @@ function templateMiddleware<Request = any, Props extends {} = EmptyObject>(name:
3130
const warnInvalid = warnOnce(`"${name}" middleware prop must be an array of function`);
3231

3332
const extractMiddleware = (
34-
middleware: readonly MiddlewareWithInit<ComponentMiddleware<unknown, unknown>, unknown>[] | undefined
33+
middleware: readonly MiddlewareWithInit<ComponentMiddleware<unknown, unknown>, string>[] | undefined
3534
): readonly Middleware[] => {
3635
if (middleware) {
3736
if (isArrayOfFunction(middleware)) {

0 commit comments

Comments
 (0)