Checks if an entity has all specified components.
Type-safe component validation. Checks both presence and non-undefined value for each component key.
The entity to check.
Component keys to check for.
True if entity has all components with non-undefined values.
const entity = { position: { x: 0, y: 0, z: 0 }, health: 100 };if (hasComponents(entity, 'position', 'health')) { // TypeScript knows entity has position and health console.log(`Health: ${entity.health}`);} Copy
const entity = { position: { x: 0, y: 0, z: 0 }, health: 100 };if (hasComponents(entity, 'position', 'health')) { // TypeScript knows entity has position and health console.log(`Health: ${entity.health}`);}
Checks if an entity has all specified components.
Type-safe component validation. Checks both presence and non-undefined value for each component key.