import { ComponentProps } from 'react'; import { Action, Method, Resource, State } from './enums'; import translations from '../../public/locales/en/toast.json'; import { GenericFunction, ObjectValues } from '@ballerine/common'; export type WithRequired = TObject & { [TProperty in TKey]-?: TObject[TProperty]; }; export type AnyArray = any[]; export type AnyRecord = Record; export type GenericAsyncFunction = (...args: AnyArray) => Promise; export type NParameter< TFunction extends GenericFunction, TIndex extends number, > = Parameters[TIndex]; export type DivComponent = ComponentProps<'div'>; export type ButtonComponent = ComponentProps<'button'>; export type TState = ObjectValues; export type TMethod = ObjectValues; export type TResource = ObjectValues; export type TAction = ObjectValues; export type TKeyofArrayElement = keyof TArray[number]; /** * Creates a new object type that omits the specified properties from the original object type. * Doing this ensures the result type is '{ example: string; }' instead of 'Omit<{ example: string; }, "example">'. */ export type TypesafeOmit, TProps extends keyof TObj> = { [TKey in Exclude]: TObj[TKey]; } & {}; export type UnknownRecord = Record; export type NoInfer = [T][T extends any ? 0 : never]; export type TToastKeyWithSuccessAndError = { [TKey in keyof typeof translations]: (typeof translations)[TKey] extends { success: string; error: string; } ? TKey : never; }[keyof typeof translations]; export type Json = string | number | boolean | null | Json[] | { [key: string]: Json }; export type ExtendedJson = | string | number | boolean | null | undefined | ExtendedJson[] | { [key: string]: ExtendedJson };