11/* eslint-disable max-lines */
2- /* eslint-disable @khanacademy/ts-no-error-suppressions */
32import { KeypadContext } from "@khanacademy/keypad-context" ;
43import { View } from "@khanacademy/wonder-blocks-core" ;
54import { color } from "@khanacademy/wonder-blocks-tokens" ;
@@ -62,21 +61,16 @@ class MathInput extends React.Component<Props, State> {
6261 didTouchOutside : boolean | null | undefined ;
6362 didScroll : boolean | null | undefined ;
6463 mathField : any ;
65- // @ts -expect-error - TS2564 - Property 'recordTouchStartOutside' has no initializer and is not definitely assigned in the constructor.
66- recordTouchStartOutside : ( arg1 : any ) => void ;
67- // @ts -expect-error - TS2564 - Property 'blurOnTouchEndOutside' has no initializer and is not definitely assigned in the constructor.
68- blurOnTouchEndOutside : ( arg1 : any ) => void ;
69- // @ts -expect-error - TS2564 - Property 'blurOnClickOutside' has no initializer and is not definitely assigned in the constructor.
70- blurOnClickOutside : ( arg1 : any ) => void ;
64+ recordTouchStartOutside ! : ( arg1 : any ) => void ;
65+ blurOnTouchEndOutside ! : ( arg1 : any ) => void ;
66+ blurOnClickOutside ! : ( arg1 : any ) => void ;
7167 dragListener : any ;
7268 inputRef : HTMLDivElement | null | undefined ;
7369 _isMounted : boolean | null | undefined ;
7470 _mathContainer : any ;
75- // @ts -expect-error - TS2564 - Property '_container' has no initializer and is not definitely assigned in the constructor.
76- _container : HTMLDivElement ;
71+ _container ! : HTMLDivElement ;
7772 _root : any ;
78- // @ts -expect-error - TS2564 - Property '_containerBounds' has no initializer and is not definitely assigned in the constructor.
79- _containerBounds : ClientRect ;
73+ _containerBounds ! : ClientRect ;
8074
8175 static defaultProps : DefaultProps = {
8276 style : { } ,
@@ -446,14 +440,13 @@ class MathInput extends React.Component<Props, State> {
446440 while ( y >= containerBounds . top && y <= containerBounds . bottom ) {
447441 y += dy ;
448442
449- const points = [
443+ const points : [ number , number ] [ ] = [
450444 [ x - dx , y ] ,
451445 [ x , y ] ,
452446 [ x + dx , y ] ,
453447 ] ;
454448
455449 const elements = points
456- // @ts -expect-error - TS2556 - A spread argument must either have a tuple type or be passed to a rest parameter.
457450 . map ( ( point ) => document . elementFromPoint ( ...point ) )
458451 // We exclude the root container itself and any nodes marked
459452 // as non-leaf which are fractions, parens, and roots. The
@@ -475,14 +468,14 @@ class MathInput extends React.Component<Props, State> {
475468 element . classList . contains ( "mq-hasCursor" ) ) ,
476469 ) ;
477470
478- let hitNode = null ;
471+ let hitNode : Element | null = null ;
479472
480473 // Contains only DOMNodes without child elements. These should
481474 // contain some amount of text though.
482- const leafElements : ReadonlyArray < null | HTMLElement > = [ ] ;
475+ const leafElements : Array < Element | null > = [ ] ;
483476
484477 // Contains only DOMNodes with child elements.
485- const nonLeafElements : ReadonlyArray < null | HTMLElement > = [ ] ;
478+ const nonLeafElements : Array < Element | null > = [ ] ;
486479
487480 let max = 0 ;
488481 const counts : {
@@ -491,17 +484,14 @@ class MathInput extends React.Component<Props, State> {
491484 const elementsById : Record < string , any > = { } ;
492485
493486 for ( const element of elements ) {
494- // @ts -expect-error - TS2531 - Object is possibly 'null'.
495- const id = element . getAttribute ( "mathquill-command-id" ) ;
487+ const id = element ?. getAttribute ( "mathquill-command-id" ) ;
496488 if ( id != null ) {
497- // @ts -expect-error - TS2345 - Argument of type 'Element | null' is not assignable to parameter of type 'HTMLElement | null'.
498489 leafElements . push ( element ) ;
499490
500491 // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
501492 counts [ id ] = ( counts [ id ] || 0 ) + 1 ;
502493 elementsById [ id ] = element ;
503494 } else {
504- // @ts -expect-error - TS2345 - Argument of type 'Element | null' is not assignable to parameter of type 'HTMLElement | null'.
505495 nonLeafElements . push ( element ) ;
506496 }
507497 }
@@ -530,7 +520,6 @@ class MathInput extends React.Component<Props, State> {
530520 // hit count in the situation should not have serious effects on
531521 // the overall accuracy of the algorithm.
532522 if ( hitNode == null && nonLeafElements . length > 0 ) {
533- // @ts -expect-error - TS2322 - Type 'HTMLElement | null' is not assignable to type 'null'.
534523 hitNode = nonLeafElements [ 0 ] ;
535524 }
536525
@@ -1001,9 +990,8 @@ class MathInput extends React.Component<Props, State> {
1001990 { /* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- TODO(LEMS-2871): Address a11y error */ }
1002991 < div
1003992 className = "keypad-input"
1004- // @ts -expect-error - TS2322 - Type 'string' is not assignable to type 'number | undefined'.
1005993 // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- TODO(LEMS-2871): Address a11y error
1006- tabIndex = { "0" }
994+ tabIndex = { 0 }
1007995 ref = { ( node ) => {
1008996 this . inputRef = node ;
1009997 } }
0 commit comments