@alanscodelog/utils
    Preparing search index...

    Function assertKeyInObjectIs

    • Asserts the key's value is the given value (runtime only, does not do types*).

      Throws nice error if it isn't. Error message is customizable.

      *This seems like a limitation of typescript for the moment. See #46184

      Type Parameters

      • T extends Record<string, any>
      • TKey extends string | number | symbol
      • TVal extends any

      Parameters

      • obj: T
      • key: TKey
      • val: TVal
      • OptionalerrorMessage: string

      Returns asserts obj is T & Record<TKey, TVal>