From c63251172cd3fa26bb147f2c0674a60326262459 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Tue, 16 Jul 2024 22:53:33 +0900 Subject: [PATCH] fix(types): remove slow types (#3147) --- src/compose.ts | 4 ++-- src/jsx/dom/hooks/index.ts | 3 ++- src/jsx/dom/render.ts | 2 +- src/jsx/intrinsic-element/components.ts | 7 +++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/compose.ts b/src/compose.ts index 1532639e..83ae97b3 100644 --- a/src/compose.ts +++ b/src/compose.ts @@ -34,8 +34,8 @@ export const compose = ( middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler, onNotFound?: NotFoundHandler -) => { - return (context: C, next?: Function) => { +): ((context: C, next?: Function) => Promise) => { + return (context, next) => { let index = -1 return dispatch(0) diff --git a/src/jsx/dom/hooks/index.ts b/src/jsx/dom/hooks/index.ts index d0102a23..c9983c29 100644 --- a/src/jsx/dom/hooks/index.ts +++ b/src/jsx/dom/hooks/index.ts @@ -2,6 +2,7 @@ * Provide hooks used only in jsx/dom */ +import type { Context } from '../../context' import { useContext } from '../../context' import { createContext } from '../context' import { useCallback, useState } from '../../hooks' @@ -20,7 +21,7 @@ type FormStatus = method: 'get' | 'post' action: string | ((formData: FormData) => void | Promise) } -export const FormContext = createContext({ +export const FormContext: Context = createContext({ pending: false, data: null, method: null, diff --git a/src/jsx/dom/render.ts b/src/jsx/dom/render.ts index e51a72d3..dbb8478b 100644 --- a/src/jsx/dom/render.ts +++ b/src/jsx/dom/render.ts @@ -344,7 +344,7 @@ const findChildNodeIndex = ( return } -const cancelBuild = Symbol() +const cancelBuild: symbol = Symbol() const applyNodeObject = (node: NodeObject, container: Container): void => { const next: Node[] = [] const remove: Node[] = [] diff --git a/src/jsx/intrinsic-element/components.ts b/src/jsx/intrinsic-element/components.ts index 0180d542..f6a4541e 100644 --- a/src/jsx/intrinsic-element/components.ts +++ b/src/jsx/intrinsic-element/components.ts @@ -168,5 +168,8 @@ const formActionableElement = ( } return newJSXNode(tag, props) } -export const input = (props: PropsWithChildren) => formActionableElement('input', props) -export const button = (props: PropsWithChildren) => formActionableElement('button', props) + +export const input: (props: PropsWithChildren) => unknown = (props) => + formActionableElement('input', props) +export const button: (props: PropsWithChildren) => unknown = (props) => + formActionableElement('button', props)