From da7d8b902b94acac33d1d7adb6b84a90f27c4503 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 30 May 2024 10:07:59 -0700 Subject: [PATCH] filter: Fix TypeScript noUncheckedIndexedAccess errors. Signed-off-by: Anders Kaseorg --- web/src/filter.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/src/filter.ts b/web/src/filter.ts index 967375ccd0..e8faac8b47 100644 --- a/web/src/filter.ts +++ b/web/src/filter.ts @@ -581,7 +581,7 @@ export class Filter { return parts; } - if (terms.length >= 2) { + if (terms[0] !== undefined && terms[1] !== undefined) { const is = (term: NarrowTerm, expected: string): boolean => Filter.canonicalize_operator(term.operator) === expected && !term.negated; @@ -1151,6 +1151,7 @@ export class Filter { filter_with_new_params(params: NarrowTerm): Filter { const new_params = this.fix_terms([params])[0]; + assert(new_params !== undefined); const terms = this._terms.map((term) => { const new_term = {...term}; if (new_term.operator === new_params.operator && !new_term.negated) {