Skip to content

Commit 2a6f192

Browse files
committed
fix: ui/ 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<HTMLElement>(':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 and fixed in a followup task.
1 parent 669d68c commit 2a6f192

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

‎patches/chromium/.patches‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,4 @@ feat_add_signals_when_embedder_cleanup_callbacks_run_for.patch
141141
feat_separate_content_settings_callback_for_sync_and_async_clipboard.patch
142142
fix_win32_synchronous_spellcheck.patch
143143
chore_remove_conflicting_allow_unsafe_libc_calls.patch
144+
fix_linter_error.patch
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Charles Kerr <charles@charleskerr.com>
3+
Date: Thu, 6 Mar 2025 17:06:49 -0600
4+
Subject: fix: linter error
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
fix: linter error
10+
11+
This is showing up in an eslint build step in Electron:
12+
13+
> /__w/electron/electron/src/out/Default/gen/ui/webui/resources/cr_elements/preprocessed/cr_menu_selector/cr_menu_selector.ts
14+
> 77:23 error This assertion is unnecessary since the receiver accepts the original type of the expression @typescript-eslint/no-unnecessary-type-assertion
15+
>
16+
> ✖ 1 problem (1 error, 0 warnings)
17+
> 1 error and 0 warnings potentially fixable with the `--fix` option.
18+
19+
However, removing the assertion causes a typescript build failure:
20+
21+
> 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'.
22+
> Type 'null' is not assignable to type 'HTMLElement'.
23+
>
24+
> 77 items.indexOf(this.querySelector<HTMLElement>(':focus'));
25+
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26+
27+
So I think the two different steps may be picking up typescript definitions.
28+
29+
This patch should be removed after the issue is tracked down
30+
andfixed in a followup task.
31+
32+
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
33+
index 0a83b8041b8201c95442e680c77555d4c11bc06a..abdb8e9bfbbfb1fce6fa38e226e50a35477e49a2 100644
34+
--- a/ui/webui/resources/cr_elements/cr_menu_selector/cr_menu_selector.ts
35+
+++ b/ui/webui/resources/cr_elements/cr_menu_selector/cr_menu_selector.ts
36+
@@ -74,6 +74,7 @@ export class CrMenuSelector extends CrMenuSelectorBase {
37+
const items = this.getAllFocusableItems_();
38+
assert(items.length >= 1);
39+
const currentFocusedIndex =
40+
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
41+
items.indexOf(this.querySelector<HTMLElement>(':focus')!);
42+
43+
let newFocusedIndex = currentFocusedIndex;

0 commit comments

Comments
 (0)