Home Declarations

On this page 4

Home uses .d.hm files for package API metadata.

They are not TypeScript .d.ts files. A .d.ts describes JavaScript runtime values to the TypeScript checker. A .d.hm describes Home package boundaries to the Home compiler, LSP, package manager, and future incremental checker.

Goals

  • Let the LSP answer completions, hovers, and auto-imports from dependencies

    without reparsing every source file.

  • Let package installs cache compact public API metadata next to package

    sources.

  • Let home check validate downstream packages against stable public surfaces.

  • Keep the format Home-native so it can represent traits, comptime values,

    ownership, effects, async, errors, and platform availability without mapping through TypeScript concepts.

Command

Generate declarations for the current package:

home pkg declarations

Useful options:

home pkg declarations --src src
home pkg declarations --out .home/declarations/my-package.d.hm

The first implementation emits a conservative top-level API index. The next step is to move extraction onto the parsed Home AST, borrowing the scanner and emitter shape from ~/Code/Tools/dtsx/packages/zig-dtsx while producing Home syntax instead of .d.ts syntax.

Example

// Generated by `home pkg declarations`.
// This is Home API metadata, not a TypeScript .d.ts file.

declare package "my-package"

// src/main.home
export fn main()
export struct User
export enum Result<T, E>

Package Layout

Generated declaration files live under:

.home/declarations/<package>.d.hm

Published packages should include this file once declaration generation is AST-backed and stable.

Released under the MIT License.