From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 6 Mar 2025 17:06:49 -0600 Subject: fix: linter error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: linter error This is showing up in an eslint build step in Electron: > /__w/electron/electron/src/out/Default/gen/ui/webui/resources/cr_elements/preprocessed/cr_menu_selector/cr_menu_selector.ts > 77:23 error This assertion is unnecessary since the receiver accepts the original type of the expression @typescript-eslint/no-unnecessary-type-assertion > > ✖ 1 problem (1 error, 0 warnings) > 1 error and 0 warnings potentially fixable with the `--fix` option. However, removing the assertion causes a typescript build failure: > gen/ui/webui/resources/cr_elements/preprocessed/cr_menu_selector/cr_menu_selector.ts:77:23 - error TS2345: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. > Type 'null' is not assignable to type 'HTMLElement'. > > 77 items.indexOf(this.querySelector(':focus')); > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So I think the two different steps may be picking up typescript definitions. This patch should be removed after the issue is tracked down andfixed in a followup task. diff --git a/ui/webui/resources/cr_elements/cr_menu_selector/cr_menu_selector.ts b/ui/webui/resources/cr_elements/cr_menu_selector/cr_menu_selector.ts index 0a83b8041b8201c95442e680c77555d4c11bc06a..abdb8e9bfbbfb1fce6fa38e226e50a35477e49a2 100644 --- a/ui/webui/resources/cr_elements/cr_menu_selector/cr_menu_selector.ts +++ b/ui/webui/resources/cr_elements/cr_menu_selector/cr_menu_selector.ts @@ -74,6 +74,7 @@ export class CrMenuSelector extends CrMenuSelectorBase { const items = this.getAllFocusableItems_(); assert(items.length >= 1); const currentFocusedIndex = + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion items.indexOf(this.querySelector(':focus')!); let newFocusedIndex = currentFocusedIndex;