bot_data: Fix TypeScript noUncheckedIndexedAccess errors.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-05-30 10:07:58 -07:00
parent 8cec7dd917
commit 6cd8c9bb8c
1 changed files with 5 additions and 1 deletions

View File

@ -78,7 +78,11 @@ export function update(bot_id: number, bot_update: ServerUpdateBotData): void {
// We currently only support one service per bot. // We currently only support one service per bot.
const service = services.get(bot_id)![0]; const service = services.get(bot_id)![0];
if (bot_update.services !== undefined && bot_update.services.length > 0) { if (
service !== undefined &&
bot_update.services !== undefined &&
bot_update.services.length > 0
) {
Object.assign(service, services_schema.parse(bot_update.services)[0]); Object.assign(service, services_schema.parse(bot_update.services)[0]);
} }
} }