import { is } from 'effector'; import type { Unit } from 'effector'; type Shape = { [key: string]: unknown }; export type OnlyUnits = Pick< T, { [Key in keyof T]-?: T[Key] extends Unit ? Key : never }[keyof T] >; export function removeNonUnit(shape: T): OnlyUnits { return Object.keys(shape).reduce((acc, key) => { const value = shape[key]; if (is.unit(value)) { // @ts-expect-error acc[key] = value; } return acc; }, {} as OnlyUnits); }