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.

narrow_state: Fix TypeScript noUncheckedIndexedAccess errors.

Anders Kaseorgdf849b294a81
diff --git a/web/src/narrow_state.ts b/web/src/narrow_state.ts
index 4079fb25999..fec4157a159 100644
--- a/web/src/narrow_state.ts
+++ b/web/src/narrow_state.ts
@@ -121,7 +121,7 @@ export function stream_name(current_filter: Filter | undefined = filter()): stri
return undefined;
}
const stream_operands = current_filter.operands("channel");
- if (stream_operands.length === 1) {
+ if (stream_operands.length === 1 && stream_operands[0] !== undefined) {
const name = stream_operands[0];
// Use get_name() to get the most current stream
@@ -139,7 +139,7 @@ export function stream_sub(
}
const stream_operands = current_filter.operands("channel");
- if (stream_operands.length !== 1) {
+ if (stream_operands.length !== 1 || stream_operands[0] === undefined) {
return undefined;
}