1- import { MouseEventHandler , MutableRefObject , useEffect , useRef , useState } from "react" ;
1+ import { ChangeEventHandler , KeyboardEventHandler , MouseEventHandler , MutableRefObject , useEffect , useRef , useState } from "react" ;
22import styles from "./Terminal.module.css" ;
33import { OutputLine } from "./OutputLine" ;
44import { InputLine } from "./InputLine" ;
@@ -118,7 +118,7 @@ export function Terminal({ app, path: startPath, input, setTitle, close: exit, a
118118 setStream ( stream ) ;
119119 setStreamFocused ( false ) ;
120120
121- const onKeyDown = ( event : KeyboardEvent ) => {
121+ const onKeyDown = ( event : globalThis . KeyboardEvent ) => {
122122 if ( active && ( event . ctrlKey || event . metaKey ) && event . key === "c" ) {
123123 stream . stop ( ) ;
124124 }
@@ -320,7 +320,7 @@ export function Terminal({ app, path: startPath, input, setTitle, close: exit, a
320320 setHistoryIndex ( index ) ;
321321 } ;
322322
323- const onKeyDown = ( event : React . KeyboardEvent ) => {
323+ const onKeyDown : KeyboardEventHandler < HTMLInputElement > = ( event ) => {
324324 const value = ( event . target as HTMLInputElement ) . value ;
325325 const { key } = event ;
326326
@@ -338,8 +338,8 @@ export function Terminal({ app, path: startPath, input, setTitle, close: exit, a
338338 }
339339 } ;
340340
341- const onChange = ( event : React . ChangeEvent ) => {
342- const value = ( event . target as HTMLInputElement ) . value ;
341+ const onChange : ChangeEventHandler < HTMLInputElement > = ( event ) => {
342+ const value = event . target . value ;
343343 return setInputValue ( value ) ;
344344 } ;
345345
@@ -357,7 +357,7 @@ export function Terminal({ app, path: startPath, input, setTitle, close: exit, a
357357 } ) ;
358358 } ;
359359
360- const onMouseDown = ( event : MouseEvent ) => {
360+ const onMouseDown : MouseEventHandler < HTMLDivElement > = ( event ) => {
361361 focus ?.( event ) ;
362362
363363 if ( event . button === 2 ) {
@@ -371,20 +371,20 @@ export function Terminal({ app, path: startPath, input, setTitle, close: exit, a
371371 }
372372 } ;
373373
374- const onContextMenu = ( event : Event ) => {
374+ const onContextMenu : MouseEventHandler < HTMLDivElement > = ( event ) => {
375375 event . preventDefault ( ) ;
376376 } ;
377377
378378 return (
379379 < div
380380 ref = { ref }
381381 className = { styles . Terminal }
382- onMouseDown = { onMouseDown as unknown as MouseEventHandler }
383- onContextMenu = { onContextMenu as unknown as MouseEventHandler }
382+ onMouseDown = { onMouseDown }
383+ onContextMenu = { onContextMenu }
384384 onClick = { ( event ) => {
385385 if ( window . getSelection ( ) ?. toString ( ) === "" ) {
386386 event . preventDefault ( ) ;
387- ( inputRef . current ) ?. focus ( ) ;
387+ inputRef . current ?. focus ( ) ;
388388 }
389389 } }
390390 >
0 commit comments