From 1c3c678883fa3aeb5afb8c987429bc9151326a5e Mon Sep 17 00:00:00 2001 From: * <*> Date: Tue, 10 Jan 2023 20:09:54 +0800 Subject: [PATCH] Match-id-9952e9ebc64f02cfbab95841eee1b1788348e9f6 --- libs/horizon/src/renderer/Types.ts | 2 ++ libs/horizon/src/renderer/UpdateHandler.ts | 4 +--- libs/horizon/src/renderer/components/BaseClassComponent.ts | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/horizon/src/renderer/Types.ts b/libs/horizon/src/renderer/Types.ts index 1503fee9..91b6bfbd 100644 --- a/libs/horizon/src/renderer/Types.ts +++ b/libs/horizon/src/renderer/Types.ts @@ -77,3 +77,5 @@ export type Source = { fileName: string; lineNumber: number; }; + +export type Callback = () => void; diff --git a/libs/horizon/src/renderer/UpdateHandler.ts b/libs/horizon/src/renderer/UpdateHandler.ts index c906bd1c..5fd17bb1 100644 --- a/libs/horizon/src/renderer/UpdateHandler.ts +++ b/libs/horizon/src/renderer/UpdateHandler.ts @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import type { VNode } from './Types'; +import type { VNode, Callback } from './Types'; import { FlagUtils, ShouldCapture } from './vnode/VNodeFlags'; export type Update = { @@ -22,8 +22,6 @@ export type Update = { callback: Callback | null; }; -export type Callback = () => any; - export type Updates = Array | null; export enum UpdateState { diff --git a/libs/horizon/src/renderer/components/BaseClassComponent.ts b/libs/horizon/src/renderer/components/BaseClassComponent.ts index 8a931e04..de4ff351 100644 --- a/libs/horizon/src/renderer/components/BaseClassComponent.ts +++ b/libs/horizon/src/renderer/components/BaseClassComponent.ts @@ -13,6 +13,8 @@ * See the Mulan PSL v2 for more details. */ +import {Callback} from '../Types'; + /** * Component的api setState和forceUpdate在实例生成阶段实现 */ @@ -29,7 +31,7 @@ class Component { this.context = context; } - setState(state: S, callback?: any) { + setState(state: S, callback?: Callback) { if (isDev) { console.error('Cant not call `this.setState` in the constructor of class component, it will do nothing'); }