• Asserts wether an object has a property and narrows down the signature

    Example

    const fruit: Fruit = { color: 'yellow' }

    if (hasProperty(fruit, 'color')) {
    console.log(fruit.color)
    }

    Type Parameters

    • T

    • K extends string | number | symbol

    Parameters

    • object: T
    • key: K

    Returns object is Omit<T, K> & Pick<Required<T>, K> & T

Generated using TypeDoc