hongluan-ui
Version:
Hongluan Component Library for Vue 3
1 lines • 2.08 kB
Source Map (JSON)
{"version":3,"file":"typescript.mjs","sources":["../../../../packages/utils/typescript.ts"],"sourcesContent":["import type { CSSProperties } from 'vue'\n\nexport const mutable = <T extends readonly any[] | Record<string, unknown>>(\n val: T,\n) => val as Mutable<typeof val>\nexport type Mutable<T> = { -readonly [P in keyof T]: T[P] }\n\nexport type HTMLElementCustomized<T> = HTMLElement & T\n\n/**\n * @deprecated stop to use null\n * @see {@link https://github.com/sindresorhus/meta/discussions/7}\n */\nexport type Nullable<T> = T | null\n\nexport type ExtractType<O, T> = { [K in keyof O]: O[K] extends T ? O[K] : unknown }\n\n// 组合两个 object 的类型\nexport type Diff<T extends string, U> = ({ [P in T]: P } &\n{ [P in keyof U]: U[P] extends string ? string : never } & {\n [x: string]: never\n})[T]\n\n// 这里我们只以 string 类型的key作为示例\nexport type ExtractStringKey<A> = Diff<Extract<keyof A, string>, ExtractType<A, string>>\n\ntype OptionalKeys<T extends Record<string, unknown>> = {\n [K in keyof T]: T extends Record<K, T[K]>\n ? never\n : K\n}[keyof T]\n\ntype RequiredKeys<T extends Record<string, unknown>> = Exclude<keyof T, OptionalKeys<T>>\n\ntype MonoArgEmitter<T, Keys extends keyof T> = <K extends Keys>(evt: K, arg?: T[K]) => void\n\ntype BiArgEmitter<T, Keys extends keyof T> = <K extends Keys>(evt: K, arg: T[K]) => void\n\nexport type EventEmitter<T extends Record<string, unknown>> =\n MonoArgEmitter<T, OptionalKeys<T>> & BiArgEmitter<T, RequiredKeys<T>>\n\nexport type AnyFunction<T> = (...args: any[]) => T\n\nexport type PartialReturnType<T extends (...args: unknown[]) => unknown> = Partial<ReturnType<T>>\n\nexport type RefElement = Nullable<HTMLElement>\n\nexport type Indexable<T> = {\n [key: string]: T\n}\n\nexport type Hash<T> = Indexable<T>\n\nexport type TimeoutHandle = number\n\nexport type StyleValue = string | CSSProperties | Array<StyleValue>\n\nexport type Arrayable<T> = T | T[]\n\nexport type Awaitable<T> = Promise<T> | T\n"],"names":[],"mappings":"AAAY,MAAC,OAAO,GAAG,CAAC,GAAG,KAAK;;;;"}