Function ensureAnyJson

  • Narrows an unknown value to an AnyJson if it is type-compatible, or returns undefined otherwise.

    See also caveats noted in isAnyJson.

    Parameters

    • value: unknown

      The value to test.

    • Optionalmessage: string

      The error message to use if value is not type-compatible.

    Returns AnyJson

    UnexpectedValueTypeError If the value was not a JSON value type.