Skip to main content

Framework - Homebridge

Configure TypeScript for a Homebridge plugin without making every Node.js project inherit Homebridge-specific compiler behavior.

Why Use This Preset?

  1. Includes DOM types used by Homebridge and plugin configuration interfaces.
  2. Allows references to the ambient HAP const enums exposed by Homebridge's type declarations.
  3. Disables verbatim module syntax, which is incompatible with those ambient const enum references in current TypeScript releases.
  4. Composes with Nova's Node runtime preset while keeping Homebridge behavior in a distinct, reviewable layer.

Usage

Add the preset after the essentials, strict, and Node runtime layers.

tsconfig.json
json
{
  "extends": [
    "@cbnventures/nova/presets/tsconfig/dx-essentials.json",
    "@cbnventures/nova/presets/tsconfig/dx-strict.json",
    "@cbnventures/nova/presets/tsconfig/runtime-node.json",
    "@cbnventures/nova/presets/tsconfig/fw-homebridge.json"
  ],
  "compilerOptions": {
    "outDir": "./build",
    "rootDir": "./src",
    "types": [
      "@types/node"
    ]
  },
  "include": [
    "./src/**/*"
  ],
  "exclude": [
    "./build/**",
    "./node_modules/**"
  ]
}

What This Preset Configures

SettingValueDescription
isolatedModulesfalsePermits Homebridge's ambient HAP const enums to be referenced.
lib["DOM", "ESNext"]Provides browser-facing configuration APIs and current ECMAScript APIs.
verbatimModuleSyntaxfalseAvoids incompatible verbatim handling of ambient const enum references.

Because TypeScript replaces lib arrays instead of merging them, add project-specific libraries such as DOM.Iterable in your local config when needed. You can also override module and moduleResolution locally when a plugin's bundler requires different resolution behavior.