• Type Guard checking for properties to exist. Workaround for microsoft/TypeScript#21732 to help to implement type guards checking subsequent property value types.

    Type Parameters

    • T

      target guarded type

    Parameters

    • value: unknown

      value to check

    • Rest ...requiredProperties: (keyof T)[]

      expected properties to exist

    Returns value is Raw<T>

    Example

    const isEditorWithUI = <T extends Editor>(value: T): value is T & EditorWithUI => {
    // first see, if required keys are available
    if (isRaw<EditorWithUI>(value, "ui")) {
    // then check these keys if they pass the type-guard
    return typeof value.ui === "object";
    }
    return false;
    };