import type {IsAny} from './is-any.d.ts'; import type {UnwrapBrandedPrimitive} from './unwrap-branded-primitive.d.ts'; /** Convert a primitive type to its string representation. Useful for typing URL parameters or converting numeric property keys to strings. Supports strings, numbers, bigints, booleans, `null`, and `undefined`. Distributes over unions and removes brands using {@link UnwrapBrandedPrimitive}, with the same limitations. Unsupported members, including symbols and objects, produce `never`. `any` produces `string`; `never` and `unknown` produce `never`. Uses TypeScript's template literal rules: non-literal `number` and `bigint` produce `${number}` and `${bigint}` patterns. This type is not the return type of `String()` or the `.toString()` function. @example ``` import type {ToString} from 'type-fest'; type Page = ToString<1 | 2>; //=> '1' | '2' type Preview = ToString; //=> 'true' | 'false' type Cursor = ToString<42n | undefined>; //=> '42' | 'undefined' type StringKeys = ToString; //=> 'name' | '0' ``` @category String @category Template literal */ export type ToString = IsAny extends true ? string : ToStringHelper : Value>; type ToStringHelper = Value extends string | number | bigint | boolean | null | undefined ? `${Value}` : never; export {};