refactor(toolkit): type source any with proper types

Genuinely type composable any usages (useStepper/useStorage/useForm/
createEventHook/useSorted/etc.) as proper generics/unknown; keep idiomatic
any-function and overload-impl signatures with comments; skipped test -> .todo.
This commit is contained in:
2026-06-15 16:55:07 +07:00
parent 44848bc9e6
commit aa2938cb34
283 changed files with 3505 additions and 3482 deletions
+1 -1
View File
@@ -142,7 +142,7 @@ export function createFilterWrapper<T extends AnyFunction>(
): (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>> {
// Promises scheduled but not yet resolved by an invocation. The filter may
// drop intermediate invokes (debounce) — they all settle on the next real one.
let pending: Array<{ resolve: (value: any) => void; reject: (reason?: unknown) => void }> = [];
let pending: Array<{ resolve: (value: Awaited<ReturnType<T>>) => void; reject: (reason?: unknown) => void }> = [];
function wrapper(this: unknown, ...args: Parameters<T>) {
return new Promise<Awaited<ReturnType<T>>>((resolve, reject) => {
+51
View File
@@ -0,0 +1,51 @@
import { nextTick } from 'vue';
import type { ComponentInternalInstance } from 'vue';
import type { VoidFunction } from '@robonen/stdlib';
import { getLifeCycleTarger } from './components';
/**
* Shared options for the `tryOn*` lifecycle helpers.
*/
export interface TryOnLifecycleOptions {
/**
* Run the callback synchronously when invoked outside a component instance
* (i.e. when there is no lifecycle hook to defer to). When `false`, the
* callback is scheduled on the next microtask via `nextTick`.
*
* @default true
*/
sync?: boolean;
/**
* The component instance the lifecycle hook should be bound to. Defaults to
* the current active instance.
*/
target?: ComponentInternalInstance;
}
/**
* The shape shared by Vue's lifecycle registrars (`onMounted`, `onBeforeMount`, …):
* a callback plus an optional target instance.
*/
type LifecycleHook = (hook: VoidFunction, target?: ComponentInternalInstance | null) => void;
/**
* Register `fn` on the given Vue lifecycle `hook` when called inside a component
* instance; otherwise run it immediately (or on the next tick when `sync` is
* `false`). Factored out so the `tryOnMounted` / `tryOnBeforeMount` helpers share
* one implementation of the instance-resolution and fallback branching.
*/
export function runTryOnLifecycle(
hook: LifecycleHook,
fn: VoidFunction,
options: TryOnLifecycleOptions = {},
): void {
const { sync = true, target } = options;
const instance = getLifeCycleTarger(target);
if (instance)
hook(fn, instance);
else if (sync)
fn();
else
nextTick(fn);
}