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:
+3
-3
@@ -149,11 +149,11 @@ const startSock = async() => {
|
||||
|
||||
// go to an old chat and send this
|
||||
if (text == "onDemandHistSync") {
|
||||
const messageId = await sock.fetchMessageHistory(50, msg.key, msg.messageTimestamp!)
|
||||
const messageId = await sock.fetchMessageHistory(50, msg.key, msg.messageTimestamp ?? 0)
|
||||
logger.debug({ id: messageId }, 'requested on-demand history resync')
|
||||
}
|
||||
|
||||
if (!msg.key.fromMe && doReplies && !isJidNewsletter(msg.key?.remoteJid!)) {
|
||||
if (!msg.key.fromMe && doReplies && !isJidNewsletter(msg.key?.remoteJid ?? '')) {
|
||||
const id = generateMessageIDV2(sock.user?.id)
|
||||
logger.debug({id, orig_id: msg.key.id }, 'replying to message')
|
||||
await sock.sendMessage(msg.key.remoteJid!, { text: 'pong '+msg.key.id }, {messageId: id })
|
||||
@@ -208,7 +208,7 @@ const startSock = async() => {
|
||||
if(typeof contact.imgUrl !== 'undefined') {
|
||||
const newUrl = contact.imgUrl === null
|
||||
? null
|
||||
: await sock!.profilePictureUrl(contact.id!).catch(() => null)
|
||||
: await sock.profilePictureUrl(contact.id ?? '').catch(() => null)
|
||||
logger.debug({id: contact.id, newUrl}, `contact has a new profile pic` )
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user