fix(typecheck): declare Ink JSX intrinsics (#1571)

This commit is contained in:
Bogdan
2026-06-10 08:53:52 +08:00
committed by GitHub
parent bf2d540efc
commit 38b2d83699
+54 -7
View File
@@ -1,9 +1,56 @@
// Stub — global types for Ink renderer
declare namespace JSX {
interface IntrinsicElements {
'ink-box': Record<string, unknown>
'ink-text': Record<string, unknown>
'ink-root': Record<string, unknown>
'ink-virtual-text': Record<string, unknown>
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<DOMElement>
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<string, unknown>
'ink-virtual-text': Record<string, unknown>
'ink-link': InkLinkElementProps
'ink-raw-ansi': InkRawAnsiElementProps
}
declare module 'react' {
namespace JSX {
interface IntrinsicElements extends InkIntrinsicElements {}
}
}