fix(types): remove non-null assertions across 14 files
Files fixed: - messages-recv.ts: 58 assertions → null guards, meId extraction, optional chaining - process-message.ts: 38 assertions → remoteJid/participant guards, proto field checks - chat-utils.ts: 31 assertions → proto field validation with Boom errors - messages-send.ts: 20 assertions → meId extraction, participant guards - chats.ts: 15 assertions → me guard, firstChild guard, jid guards - messages.ts: 14 assertions → originalFilePath guard, key guards - groups.ts: 12 assertions → attrs fallbacks with ?? - validate-connection.ts: 9 assertions → grouped proto field validation - generics.ts: 1 assertion → versionLine guard - history.ts: 2 assertions → key guards - libsignal.ts: 1 assertion → deviceId guard - sender-key-message.ts: 3 assertions → proto guards - UsyncBotProfileProtocol.ts: 2 assertions → attrs guards - example.ts: 3 assertions → optional chaining https://claude.ai/code/session_01E2cfX1N3sJgCJBTvzGazSG
This commit is contained in:
@@ -35,7 +35,7 @@ export class USyncBotProfileProtocol implements USyncQueryProtocol {
|
||||
return {
|
||||
tag: 'bot',
|
||||
attrs: {},
|
||||
content: [{ tag: 'profile', attrs: { persona_id: user.personaId! } }]
|
||||
content: [{ tag: 'profile', attrs: { persona_id: user.personaId ?? '' } }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,24 +51,24 @@ export class USyncBotProfileProtocol implements USyncQueryProtocol {
|
||||
|
||||
for (const command of getBinaryNodeChildren(commandsNode, 'command')) {
|
||||
commands.push({
|
||||
name: getBinaryNodeChildString(command, 'name')!,
|
||||
description: getBinaryNodeChildString(command, 'description')!
|
||||
name: getBinaryNodeChildString(command, 'name') ?? '',
|
||||
description: getBinaryNodeChildString(command, 'description') ?? ''
|
||||
})
|
||||
}
|
||||
|
||||
for (const prompt of getBinaryNodeChildren(promptsNode, 'prompt')) {
|
||||
prompts.push(`${getBinaryNodeChildString(prompt, 'emoji')!} ${getBinaryNodeChildString(prompt, 'text')!}`)
|
||||
prompts.push(`${getBinaryNodeChildString(prompt, 'emoji') ?? ''} ${getBinaryNodeChildString(prompt, 'text') ?? ''}`)
|
||||
}
|
||||
|
||||
return {
|
||||
isDefault: !!getBinaryNodeChild(profile, 'default'),
|
||||
jid: node.attrs.jid!,
|
||||
name: getBinaryNodeChildString(profile, 'name')!,
|
||||
attributes: getBinaryNodeChildString(profile, 'attributes')!,
|
||||
description: getBinaryNodeChildString(profile, 'description')!,
|
||||
category: getBinaryNodeChildString(profile, 'category')!,
|
||||
personaId: profile!.attrs['persona_id']!,
|
||||
commandsDescription: getBinaryNodeChildString(commandsNode, 'description')!,
|
||||
jid: node.attrs.jid ?? '',
|
||||
name: getBinaryNodeChildString(profile, 'name') ?? '',
|
||||
attributes: getBinaryNodeChildString(profile, 'attributes') ?? '',
|
||||
description: getBinaryNodeChildString(profile, 'description') ?? '',
|
||||
category: getBinaryNodeChildString(profile, 'category') ?? '',
|
||||
personaId: profile?.attrs['persona_id'] ?? '',
|
||||
commandsDescription: getBinaryNodeChildString(commandsNode, 'description') ?? '',
|
||||
commands,
|
||||
prompts
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user