Skip to content

hap-fluent / CharacteristicType

Type Alias: CharacteristicType<TService, TCharName>

ts
type CharacteristicType<TService, TCharName> = TService extends {
  characteristics: infer C;
} ? C extends Record<TCharName, infer Char> ? Char : never : never;

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

Extract the FluentCharacteristic<T> type for a named characteristic on a service.

Type Parameters

Type ParameterDescription
TServiceA FluentService type.
TCharName extends stringThe camelCase characteristic name string.

Example

typescript
type OnChar = CharacteristicType<FluentService<typeof hap.Service.Lightbulb>, 'on'>;
// Result: FluentCharacteristic<boolean>

Released under the Apache-2.0 License.