fix(types): remove non-null assertions in remaining 12 files
Files fixed: - messages-media.ts: stream/buffer guards, file path validation - decode-wa-message.ts: message field guards, optional chaining - version-cache.ts: narrowing after null checks - jid-utils.ts: split result guards, user fallbacks - communities.ts: attrs fallbacks with ?? operator - sticker-pack.ts: response guards - business.ts: attrs guards - socket.ts: onClose guard, pairingCode guard, creds.me guard - event-buffer.ts: null guards - signal.ts: null guards - encode.ts (WAM): id null check with continue - upstream history.ts: conversations/pushnames null guards All 26 files across the project are now corrected. Total: ~248 non-null assertions replaced with proper null guards. https://claude.ai/code/session_01E2cfX1N3sJgCJBTvzGazSG
This commit is contained in:
@@ -194,9 +194,13 @@ export const processHistoryMessage = (item: proto.IHistorySync) => {
|
||||
case proto.HistorySync.HistorySyncType.RECENT:
|
||||
case proto.HistorySync.HistorySyncType.FULL:
|
||||
case proto.HistorySync.HistorySyncType.ON_DEMAND:
|
||||
for (const chat of item.conversations! as Chat[]) {
|
||||
for (const chat of (item.conversations ?? []) as Chat[]) {
|
||||
if (!chat.id) {
|
||||
continue
|
||||
}
|
||||
|
||||
contacts.push({
|
||||
id: chat.id!,
|
||||
id: chat.id,
|
||||
name: chat.name || undefined,
|
||||
lid: chat.lidJid || undefined,
|
||||
phoneNumber: chat.pnJid || undefined
|
||||
@@ -204,7 +208,7 @@ export const processHistoryMessage = (item: proto.IHistorySync) => {
|
||||
|
||||
// Source 2: Extract from conversation metadata
|
||||
addLidPnMapping(
|
||||
extractLidPnFromConversation(chat.id!, chat.lidJid, chat.pnJid)
|
||||
extractLidPnFromConversation(chat.id, chat.lidJid, chat.pnJid)
|
||||
)
|
||||
|
||||
const msgs = chat.messages || []
|
||||
@@ -242,7 +246,7 @@ export const processHistoryMessage = (item: proto.IHistorySync) => {
|
||||
message.messageStubParameters?.[0]
|
||||
) {
|
||||
contacts.push({
|
||||
id: message.key.participant || message.key.remoteJid!,
|
||||
id: message.key.participant || message.key.remoteJid || '',
|
||||
verifiedName: message.messageStubParameters?.[0]
|
||||
})
|
||||
}
|
||||
@@ -253,8 +257,12 @@ export const processHistoryMessage = (item: proto.IHistorySync) => {
|
||||
|
||||
break
|
||||
case proto.HistorySync.HistorySyncType.PUSH_NAME:
|
||||
for (const c of item.pushnames!) {
|
||||
contacts.push({ id: c.id!, notify: c.pushname! })
|
||||
for (const c of item.pushnames ?? []) {
|
||||
if (!c.id) {
|
||||
continue
|
||||
}
|
||||
|
||||
contacts.push({ id: c.id, notify: c.pushname ?? '' })
|
||||
}
|
||||
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user