@@ -22,7 +22,7 @@ import type { VirtualCommandArgs } from "./commands/types.js";
2222 * issues by Guidepup's usage of node builtins etc.
2323 */
2424
25- const MacOSModifiers = {
25+ const MacOSModifiers : Record < string , string > = {
2626 /**
2727 * The Command (alias cmd, ⌘) key.
2828 */
@@ -53,7 +53,7 @@ const MacOSModifiers = {
5353 ShiftRight : "shift" ,
5454} ;
5555
56- const WindowsModifiers = {
56+ const WindowsModifiers : Record < string , string > = {
5757 /**
5858 * Hold down the Control (alias ctrl, ⌃) key.
5959 */
@@ -214,8 +214,8 @@ export class Virtual implements ScreenReader {
214214 }
215215 }
216216
217- #createCursor( root : Root ) {
218- if ( ! root . document ) {
217+ #createCursor( root : Root | undefined ) {
218+ if ( ! root ? .document ) {
219219 return ;
220220 }
221221
@@ -235,7 +235,7 @@ export class Virtual implements ScreenReader {
235235 this . #cursor. style . zIndex = "calc(Infinity)" ;
236236 this . #cursor. dataset . testid = "virtual-screen-reader-cursor" ;
237237
238- this . #container. appendChild ( this . #cursor) ;
238+ this . #container! . appendChild ( this . #cursor) ;
239239 }
240240
241241 #setActiveNode( accessibilityNode : AccessibilityNode ) {
@@ -283,7 +283,7 @@ export class Virtual implements ScreenReader {
283283 * REF: https://www.w3.org/TR/wai-aria-1.2/#aria-modal
284284 */
285285 return tree . filter (
286- ( { parentDialog } ) => this . #activeNode. parentDialog === parentDialog
286+ ( { parentDialog } ) => this . #activeNode! . parentDialog === parentDialog
287287 ) ;
288288 }
289289
@@ -310,7 +310,7 @@ export class Virtual implements ScreenReader {
310310 } ) ;
311311 }
312312
313- async #handleFocusChange( { target } : FocusEvent ) {
313+ async #handleFocusChange( { target } : Event ) {
314314 await tick ( ) ;
315315
316316 this . #invalidateTreeCache( ) ;
@@ -322,15 +322,15 @@ export class Virtual implements ScreenReader {
322322 // executing... we are waiting for event loop tick so perhaps there is a
323323 // race condition here?).
324324 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
325- const newActiveNode = tree . find ( ( { node } ) => node === target ) ;
325+ const newActiveNode = tree . find ( ( { node } ) => node === target ) ! ;
326326
327327 this . #updateState( newActiveNode , true ) ;
328328 }
329329
330330 #focusActiveElement( ) {
331331 // Is only called following a null guard for `this.#activeNode`.
332332 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
333- const target = getElementNode ( this . #activeNode) as HTMLElement ;
333+ const target = getElementNode ( this . #activeNode! ) as HTMLElement ;
334334 target ?. focus ( ) ;
335335 }
336336
@@ -383,7 +383,7 @@ export class Virtual implements ScreenReader {
383383 const tree = this . #getAccessibilityTree( ) ;
384384 const parentDialogNode = tree . find (
385385 ( { node } ) => node === accessibilityNode . parentDialog
386- ) ;
386+ ) ! ;
387387
388388 const spokenPhrase = getSpokenPhrase ( parentDialogNode ) ;
389389 const itemText = getItemText ( parentDialogNode ) ;
@@ -409,7 +409,7 @@ export class Virtual implements ScreenReader {
409409 this . #spokenPhraseLog. push ( spokenPhrase ) ;
410410 }
411411
412- async #refreshState( ignoreIfNoChange ) {
412+ async #refreshState( ignoreIfNoChange : boolean ) {
413413 await tick ( ) ;
414414
415415 this . #invalidateTreeCache( ) ;
@@ -583,7 +583,7 @@ export class Virtual implements ScreenReader {
583583 // prompts the missing container error.
584584 async start (
585585 { container, displayCursor = false , window : root } : StartOptions = {
586- container : null ,
586+ container : null as never ,
587587 displayCursor : false ,
588588 }
589589 ) {
@@ -647,11 +647,11 @@ export class Virtual implements ScreenReader {
647647 this . #invalidateTreeCache( ) ;
648648
649649 if ( this . #cursor) {
650- this . #container. removeChild ( this . #cursor) ;
650+ this . #container? .removeChild ( this . #cursor) ;
651651 this . #cursor = null ;
652652 }
653653
654- this . #setActiveNode ( null ) ;
654+ this . #activeNode = null ;
655655 this . #container = null ;
656656 this . #itemTextLog = [ ] ;
657657 this . #spokenPhraseLog = [ ] ;
0 commit comments