From d405f8e79401c914331768fa133ce853847077cf Mon Sep 17 00:00:00 2001 From: Ross van Zyl Date: Sat, 10 Jan 2026 14:45:37 -0500 Subject: [PATCH] fix: add missing `state` getter to type definitions The Noble class exposes a `state` getter property that returns the current Bluetooth adapter state, but this was missing from the TypeScript definitions. Only the internal `_state` property was declared. This adds: - `state` getter with proper typing - `NobleState` type alias for the state union type Fixes usage like `noble.state === "poweredOn"` which previously caused TypeScript error TS2551. --- index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 8cbb4aa6..3cfdbd63 100644 --- a/index.d.ts +++ b/index.d.ts @@ -48,7 +48,10 @@ export declare function removeListener(event: string, listener: Function): event export declare function removeAllListeners(event?: string): events.EventEmitter; -export var _state: "unknown" | "resetting" | "unsupported" | "unauthorized" | "poweredOff" | "poweredOn"; +export type NobleState = "unknown" | "resetting" | "unsupported" | "unauthorized" | "poweredOff" | "poweredOn"; + +export var state: NobleState; +export var _state: NobleState; export var _bindings: any;