Test if an object has a specific property.
The object type
The property key to check
1.1.0
Distinguishes between properties that are missing vs. undefined. Useful for generic type checks in mapped or conditional types.
type Obj = { a: string; b?: number };type Has_a = HasProperty< Obj, 'a' >; // truetype Has_c = HasProperty< Obj, 'c' >; // false Copy
type Obj = { a: string; b?: number };type Has_a = HasProperty< Obj, 'a' >; // truetype Has_c = HasProperty< Obj, 'c' >; // false
Test if an object has a specific property.