Skip to content

hap-fluent / CharacteristicNames

Type Alias: CharacteristicNames<T>

ts
type CharacteristicNames<T> = T extends {
  characteristics: infer C;
} ? C extends Record<string, unknown> ? keyof C : never : never;

Defined in: packages/hap-fluent/src/type-utils.ts:32

Extract the camelCase characteristic name union from a FluentService type.

Type Parameters

Type ParameterDescription
TA FluentService type or any object with a characteristics property.

Remarks

Useful when you need to constrain a key parameter to valid characteristic names for a specific service type, or when generating type-safe state objects.

Example

typescript
type LightbulbChars = CharacteristicNames<FluentService<typeof hap.Service.Lightbulb>>;
// Result: 'on' | 'brightness' | 'hue' | 'saturation' | ...

Released under the Apache-2.0 License.