From 6973465d46615bf4f91163df3b6649c6fbb705a8 Mon Sep 17 00:00:00 2001 From: Robin Bolscher Date: Thu, 19 Mar 2026 11:48:33 +0100 Subject: [PATCH] fix(types): narrow index signature to `on${string}` template literal Prevents typos on non-handler properties from silently compiling. --- index.d.ts | 2 +- scripts/generate-types.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3810013..0900b62 100644 --- a/index.d.ts +++ b/index.d.ts @@ -35,7 +35,7 @@ type ZCLEnum8Status = 'SUCCESS' | 'FAILURE' | 'NOT_AUTHORIZED' | 'RESERVED_FIELD export interface ZCLNodeCluster extends EventEmitter { /** Dynamic command handler methods (e.g. `onZoneStatusChangeNotification`). */ - [key: string]: unknown; + [key: `on${string}`]: unknown; discoverCommandsGenerated(params?: { startValue?: number; diff --git a/scripts/generate-types.js b/scripts/generate-types.js index 4c71042..1f5097f 100644 --- a/scripts/generate-types.js +++ b/scripts/generate-types.js @@ -287,7 +287,7 @@ type ZCLEnum8Status = ${zclTypeToTS(ZCLDataTypes.enum8Status, false)}; // Base ZCLNodeCluster interface lines.push(`export interface ZCLNodeCluster extends EventEmitter { /** Dynamic command handler methods (e.g. \`onZoneStatusChangeNotification\`). */ - [key: string]: unknown; + [key: \`on\${string}\`]: unknown; discoverCommandsGenerated(params?: { startValue?: number;