Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

typeahead_helper: Fix TypeScript noUncheckedIndexedAccess errors.

Anders Kaseorg83eb0a326a39
diff --git a/web/src/typeahead_helper.ts b/web/src/typeahead_helper.ts
index 57cd457cf6d..c56e9f28d19 100644
--- a/web/src/typeahead_helper.ts
+++ b/web/src/typeahead_helper.ts
@@ -58,8 +58,7 @@ export function highlight_with_escaping_and_regex(regex: RegExp, item: string):
const pieces = item.split(regex).filter(Boolean);
let result = "";
- for (let i = 0; i < pieces.length; i += 1) {
- const piece = pieces[i];
+ for (const [i, piece] of pieces.entries()) {
if (regex.test(piece) && (i === 0 || pieces[i - 1].endsWith(" "))) {
// only highlight if the matching part is a word prefix, ie
// if it is the 1st piece or if there was a space before it