Skip to content

Comments

fix: export Key, KeyAction, Mods, DirtyState as runtime values#130

Merged
sreya merged 2 commits intocoder:mainfrom
oneilltomhq:fix/export-runtime-enums
Feb 24, 2026
Merged

fix: export Key, KeyAction, Mods, DirtyState as runtime values#130
sreya merged 2 commits intocoder:mainfrom
oneilltomhq:fix/export-runtime-enums

Conversation

@oneilltomhq
Copy link
Contributor

Problem

Fixes #129

lib/index.ts exports Key, KeyAction, and Mods as type-only (line 75), which strips their runtime values from the JS bundle. Consumers who do:

import { Key, KeyAction, Mods } from 'ghostty-web';

get undefined at runtime, even though the .d.ts declares them as real enums. This makes it impossible to construct a KeyEvent for KeyEncoder.encode() without manually duplicating the enum values.

Additionally, DirtyState (defined in types.ts, re-exported from ghostty.ts) is never included in index.ts, so it is not part of the public API.

CellFlags and KeyEncoderOption are already exported correctly as values — these four are the only ones affected.

Fix

  • Changed Key, KeyAction, Mods from export type { ... } to export { ... } so they appear as runtime values in the bundle.
  • Added DirtyState to the re-export from ./ghostty, alongside the existing CellFlags and KeyEncoderOption.

Verification

  • tsc --noEmit passes
  • biome check passes
  • vite build succeeds
  • All four enums confirmed as named exports in dist/ghostty-web.js
  • .d.ts still declares all six enums correctly
  • Test suite results identical to main (38 pass, 290 fail — the failures are a pre-existing happy-dom WASM fetch issue unrelated to this change)

@sreya sreya merged commit 65ed96f into coder:main Feb 24, 2026
5 checks passed
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.

Key, KeyAction, Mods are undefined at runtime; DirtyState not exported

2 participants