From 38b2d836990ab97d04a906bd967441dafc017fe1 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 10 Jun 2026 03:53:52 +0300 Subject: [PATCH] fix(typecheck): declare Ink JSX intrinsics (#1571) --- src/ink/global.d.ts | 61 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/src/ink/global.d.ts b/src/ink/global.d.ts index 925832349..44968c84c 100644 --- a/src/ink/global.d.ts +++ b/src/ink/global.d.ts @@ -1,9 +1,56 @@ -// Stub — global types for Ink renderer -declare namespace JSX { - interface IntrinsicElements { - 'ink-box': Record - 'ink-text': Record - 'ink-root': Record - 'ink-virtual-text': Record +import type { ReactNode, Ref } from 'react' +import type { DOMElement } from './dom.js' +import type { ClickEvent } from './events/click-event.js' +import type { FocusEvent } from './events/focus-event.js' +import type { KeyboardEvent } from './events/keyboard-event.js' +import type { Styles, TextStyles } from './styles.js' + +type InkBoxElementProps = { + ref?: Ref + children?: ReactNode + style?: Styles + tabIndex?: number + autoFocus?: boolean + onClick?: (event: ClickEvent) => void + onFocus?: (event: FocusEvent) => void + onFocusCapture?: (event: FocusEvent) => void + onBlur?: (event: FocusEvent) => void + onBlurCapture?: (event: FocusEvent) => void + onKeyDown?: (event: KeyboardEvent) => void + onKeyDownCapture?: (event: KeyboardEvent) => void + onMouseEnter?: () => void + onMouseLeave?: () => void + stickyScroll?: boolean +} + +type InkTextElementProps = { + children?: ReactNode + style?: Styles + textStyles?: TextStyles +} + +type InkLinkElementProps = { + children?: ReactNode + href?: string +} + +type InkRawAnsiElementProps = { + rawText: string + rawWidth: number + rawHeight: number +} + +type InkIntrinsicElements = { + 'ink-box': InkBoxElementProps + 'ink-text': InkTextElementProps + 'ink-root': Record + 'ink-virtual-text': Record + 'ink-link': InkLinkElementProps + 'ink-raw-ansi': InkRawAnsiElementProps +} + +declare module 'react' { + namespace JSX { + interface IntrinsicElements extends InkIntrinsicElements {} } }