opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(tui): add KeyEvent type annotation to useKeyboard callback

Open CasualDeveloper opened this issue 4 days ago • 1 comments

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

  • [x] bun turbo typecheck passes
  • [x] Pre-push hooks pass

Fixes #7441

CasualDeveloper avatar Jan 09 '26 08:01 CasualDeveloper