import { CamelCase } from '.'; import { AssertString } from './String.types'; export type ToColonSingle = '' | `:${Exclude}`; /** * Constructs a string type by concatenating three parts: `T`, `U`, and `V`, * separated by colons. The `U` and `V` parts are processed by the `ToColonSingle` * utility type before concatenation. * * @template T - The first part of the resulting string, must be a string or number. * @template U - The second part of the resulting string, must be a string or number. * @template V - The third part of the resulting string, must be a string or number, defaults to an empty string. */ export type ToAttr = `${T}${ToColonSingle}${ToColonSingle}`; /** * Constructs a type that represents a chain of attributes. * * @template T - The first attribute type, which can be a string or number. * @template U - The second attribute type, which can be a string or number. * @template V - The third attribute type, which can be a string or number. Defaults to an empty string. * * @remarks * This type combines the attributes using the `ToAttr` and `ToColonSingle` utility types. * It allows for a chain of attributes where the second attribute `U` is excluded if it is an empty string. * * @example * ```typescript * type Example1 = ToAttrChain<'attr1', 'attr2'>; // Results in ToAttr<'attr1', 'attr2', ''> | 'attr2' | '' * type Example2 = ToAttrChain<'attr1', 'attr2', 'attr3'>; // Results in ToAttr<'attr1', 'attr2', 'attr3'> | 'attr2:attr3' | 'attr3' * ``` */ export type ToAttrChain = ToAttr | `${Exclude}${ToColonSingle}` | V; /** */ export type KebabToCamel> = { [K in keyof T as CamelCase>]: T[K]; }; /** */ export type TypeFlatter> = { [K in keyof T]: T[K]; }; /** ⚠️ This doesn't work yet: https://github.com/vuejs/core/issues/8286 * @deprecated */ export type ToVueProps> = { [K in keyof (T & { modelValue: T['model'] extends any ? unknown : never; }) as 'model' extends K ? never : CamelCase>]: 'modelValue' extends K ? T['model'] : T[K]; }; export type ToPayloadTuple = NonNullable extends void ? [] : [payload: NonNullable]; /** ⚠️ This doesn't work yet: https://github.com/vuejs/core/issues/8286 * @deprecated */ export type ToVueEmit> = { -readonly [K in keyof Omit]-?: ToPayloadTuple; } & (Required['change'] extends undefined ? {} : { 'update:modelValue': ToPayloadTuple; });