Function identity

  • Returns the passed argument. This function is a macro that compiles to just arg.

    This is useful for ensuring that a value matches the given type in areas where it is not directly possible to do so.

    Type Parameters

    • T

    Parameters

    • arg: T

    Returns T

    Example

    type P = { x: number, y: number };
    const obj = {
    pos: identity<P>({ x: 5, y: 10 });
    }