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:
Claude
2026-02-09 00:32:04 +00:00
parent 7e88ddb858
commit 1c9fb86cc3
12 changed files with 215 additions and 104 deletions
+16 -4
View File
@@ -118,14 +118,18 @@ export const makeBusinessSocket = (config: SocketConfig) => {
content: [
{
tag: 'cover_photo',
attrs: { id: String(fbid), op: 'update', token: meta_hmac!, ts: String(ts) }
attrs: { id: String(fbid), op: 'update', token: meta_hmac ?? '', ts: String(ts) }
}
]
}
]
})
return fbid!
if (!fbid) {
throw new Error('Cover photo upload failed: missing fbid')
}
return fbid
}
const removeCoverPhoto = async (id: string) => {
@@ -332,7 +336,11 @@ export const makeBusinessSocket = (config: SocketConfig) => {
const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit')
const productNode = getBinaryNodeChild(productCatalogEditNode, 'product')
return parseProductNode(productNode!)
if (!productNode) {
throw new Error('Product node not found in catalog edit response')
}
return parseProductNode(productNode)
}
const productCreate = async (create: ProductCreate) => {
@@ -372,7 +380,11 @@ export const makeBusinessSocket = (config: SocketConfig) => {
const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add')
const productNode = getBinaryNodeChild(productCatalogAddNode, 'product')
return parseProductNode(productNode!)
if (!productNode) {
throw new Error('Product node not found in catalog add response')
}
return parseProductNode(productNode)
}
const productDelete = async (productIds: string[]) => {