[PR #7443] fix(tui): add KeyEvent type to useKeyboard callback (#7441) #12405

Closed
opened 2026-02-16 18:17:19 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7443

State: closed
Merged: No


Summary

  • Add explicit KeyEvent type import from @opentui/core
  • Annotate useKeyboard callback parameter with KeyEvent type to fix TypeScript error

Problem

The useKeyboard callback in dialog.tsx uses evt.stopPropagation(), but TypeScript reports:

TS2339: Property 'stopPropagation' does not exist on type 'KeyEvent'

This happens because @opentui/solid's jsx-runtime.d.ts imports from ./dist which contains auto-generated declarations with callback: any, shadowing the properly-typed exports.

Solution

Import KeyEvent from @opentui/core (which has proper type definitions) and explicitly annotate the callback parameter:

import { Renderable, RGBA, type KeyEvent } from "@opentui/core"

useKeyboard((evt: KeyEvent) => {
  // ...
  evt.stopPropagation()  // Now properly typed
})

Test Plan

  • bun turbo typecheck passes
  • Pre-push hooks pass

Fixes #7441

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7443 **State:** closed **Merged:** No --- ## Summary - Add explicit `KeyEvent` type import from `@opentui/core` - Annotate `useKeyboard` callback parameter with `KeyEvent` type to fix TypeScript error ## Problem The `useKeyboard` callback in `dialog.tsx` uses `evt.stopPropagation()`, but TypeScript reports: ``` TS2339: Property 'stopPropagation' does not exist on type 'KeyEvent' ``` This happens because `@opentui/solid`'s `jsx-runtime.d.ts` imports from `./dist` which contains auto-generated declarations with `callback: any`, shadowing the properly-typed exports. ## Solution Import `KeyEvent` from `@opentui/core` (which has proper type definitions) and explicitly annotate the callback parameter: ```typescript import { Renderable, RGBA, type KeyEvent } from "@opentui/core" useKeyboard((evt: KeyEvent) => { // ... evt.stopPropagation() // Now properly typed }) ``` ## Test Plan - [x] `bun turbo typecheck` passes - [x] Pre-push hooks pass Fixes #7441
yindo added the pull-request label 2026-02-16 18:17:19 -05:00
yindo closed this issue 2026-02-16 18:17:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12405