Type alias Alias<T>

Alias<T>: T | T & {
    valueOf(): T;
}

Type helper Aliasing any provided Type. By looping a Type through this Alias type helper, the dereferencing of this Type is prohibited. Use this helper to, e.g., force a string literal type to be treated as an unique type and not to be dereferenced.

Type Parameters

  • T

    The type that should be Aliased.

Example

Alias the ${number} ${'<' | '>'} ${number} type:

import { type Alias } from '@sgrud/core';

type Helper = Alias<`${number} ${'<' | '>'} ${number}`>;

const negative: Helper = '-01 < +0.1'; // negative: Helper
const positive: Helper = 'one is > 0'; // not assignable to type 'Helper'

Remarks

https://github.com/microsoft/TypeScript/issues/47828

Generated using TypeDoc