All files / types literal-union.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11                     
/**
 * A union of known literals that still accepts any value of the base type, without losing autocompletion
 * of the literals (a plain `'a' | 'b' | string` collapses to `string`).
 *
 * @template L - The suggested literals.
 * @template B - The accepted base type.
 * @example
 * type FontFamily = LiteralUnion<'monospace' | 'sans-serif', string>;
 */
export type LiteralUnion<L extends B, B extends number | string> = L | (B & Record<never, never>);