Skip to content

Conversation

@rossvz
Copy link

@rossvz rossvz commented Jan 10, 2026

Summary

  • Adds the missing state getter property to TypeScript definitions
  • Adds NobleState type alias for better reusability

Problem

The Noble class exposes a state getter property (defined in lib/noble.js lines 72-79) that returns the current Bluetooth adapter state. However, the TypeScript definitions only declared the internal _state property, not the public state getter.

This caused TypeScript error TS2551 when using noble.state:

error TS2551: Property 'state' does not exist on type 'typeof import("@abandonware/noble")'. Did you mean '_state'?

Solution

Added the state getter declaration alongside the existing _state declaration, and created a NobleState type alias for the state union type.

Test plan

  • Verified the fix resolves TS2551 in a project using noble.state === "poweredOn"

🤖 Generated with Claude Code

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.
@rzr
Copy link

rzr commented Jan 11, 2026

May I suggest to upstream the patch first to this other repo:

#356

cc: @stoprocent and @Apollon77

@Apollon77
Copy link

Thanks @rzr ... I think the fork from
@stoprocent went ahead already a lot and got more cleanups especially to types. So would be interesting if it is still relevant there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants