@@ -13,13 +13,13 @@ import {
13
13
} from "hap-nodejs" ;
14
14
import { PlatformName , PluginIdentifier , PluginName } from "./api" ;
15
15
16
- export interface SerializedPlatformAccessory extends SerializedAccessory {
16
+ export type UnknownContext = Record < string , unknown > ;
17
+
18
+ export interface SerializedPlatformAccessory < T extends UnknownContext = UnknownContext > extends SerializedAccessory {
17
19
18
20
plugin : PluginName ;
19
21
platform : PlatformName ;
20
-
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- context : Record < string , any > ;
22
+ context : T ;
23
23
24
24
}
25
25
@@ -35,7 +35,8 @@ export declare interface PlatformAccessory {
35
35
36
36
}
37
37
38
- export class PlatformAccessory extends EventEmitter {
38
+
39
+ export class PlatformAccessory < T extends UnknownContext = UnknownContext > extends EventEmitter {
39
40
40
41
// somewhat ugly way to inject custom Accessory object, while not changing the publicly exposed constructor signature
41
42
private static injectedAccessory ?: Accessory ;
@@ -59,8 +60,7 @@ export class PlatformAccessory extends EventEmitter {
59
60
/**
60
61
* This is a way for Plugin developers to store custom data with their accessory
61
62
*/
62
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
- public context : Record < string , any > = { } ; // providing something to store
63
+ public context : T = { } as T ; // providing something to store
64
64
65
65
constructor ( displayName : string , uuid : string , category ?: Categories ) { // category is only useful for external accessories
66
66
super ( ) ;
0 commit comments