Preparing search index...
    • Checks if a value matches a specific object type structure

      Type Parameters

      • T

      Parameters

      • val: unknown

        The value to check

      • keys: (keyof T)[]

        Array of required keys for the type T

      Returns boolean

      True if the value has all required keys (allows extra keys for optional fields)

      interface User { name: string; age: number; }
      isOfType<User>(obj, ["name", "age"]) // true if obj has name and age properties
      isOfType<User>({name: "John", age: 30, extra: "ok"}, ["name", "age"]) // true (extra keys allowed)