export interface Base { id: number createdAt: string | null updatedAt: string | null deletedAt?: string | null } export interface CodeName { name: string code: string } export interface TreeItem { value: string label: string hasChildren: boolean children?: TreeItem[] } export function genBase(): Base { return { id: 0, createdAt: '', updatedAt: '', } } export type WithBase = Omit & Required /** * The function `withBase` sets default values for item properties if not provided. * @param item - The `withBase` function takes in an optional parameter `item`, which is a * partial object of type `T`. The function merges the properties of `item` with default values for * `id`, `createdAt`, `updatedAt`, and `deletedAt`. The function then returns an object of type * @returns The `withBase` function returns an object with default values for the properties * `id`, `createdAt`, `updatedAt`, and `deletedAt`, along with any additional properties provided in * the `item` parameter. The returned object has a type `WithBase`, which extends `T` and * includes the default properties. */ export function withBase(item: Partial = {}): WithBase { return { id: 0, createdAt: null, updatedAt: null, deletedAt: null, ...item, } as WithBase }