UNPKG

@cuppachino/type-space

Version:

A collection of type utilities for TypeScript.

13 lines (12 loc) 433 B
import type { NumberLiteral } from '../number-literal'; /** * Coerce either a `number` or a `NumberLiteral` into a `NumberLiteral`. * * @remarks This is useful for finalizing a `NumberLike` into a `NumberLiteral`. * @example * ``` * type A = IntoNumberLiteral<1> // "1" * type B = IntoNumberLiteral<"1"> // "1" * ``` */ export type IntoNumberLiteral<T extends number | NumberLiteral> = T extends NumberLiteral ? T : `${T}`;