Check if an object has the specified properties with the specified types. Ideal for quick runtime type checking of
API responses if you don't need a full schema validation.
Example
constvalidated = hasProps(obj, { id:"string", age:"number" }); if (validated) { // obj is runtime validated and type is now narrowed down to { id: string; age: number } console.log(obj.id, obj.age); }
Check if an object has the specified properties with the specified types. Ideal for quick runtime type checking of API responses if you don't need a full schema validation.
Example