通用工具类型

This commit is contained in:
maofeng 2025-06-19 22:39:16 +08:00
parent c33ccc6d5f
commit 43b445c10b

14
src/core/types.ts Normal file
View File

@ -0,0 +1,14 @@
import { Dispatch, SetStateAction } from "react";
export type ValueGetter<T> = () => T;
export type ValueSetter<T> = (value: T) => void;
export type AsyncGetter<T> = () => Promise<T>;
export type AsyncSetter<T> = (value: T) => Promise<void>;
export type Validator<T> = (value: T) => boolean;
export type AsyncValidator<T> = (value: T) => Promise<boolean>;
export type Transformer<T, R> = (value: T) => R;
export type SetState<T> = Dispatch<SetStateAction<T>>;