Type alias Assign<S, T>

Assign<S, T>: {
    [K in keyof (S & T)]: K extends keyof S
        ? S[K]
        : K extends keyof T
            ? T[K]
            : never
}

Type helper Assigning the own property types of all of the enumerable own properties from a source type to a target type.

Type Parameters

  • S

    The source type to Assign from.

  • T

    The target type to Assign to.

Example

Assign valueOf() to string:

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

const str = 'Hello world' as Assign<{
valueOf(): 'Hello world';
}, string>;

Generated using TypeDoc