fix(types): resolve all TypeScript compilation errors from non-null assertion removal

Fixes:
- chats.ts: revert encodeResult/initial to ! (guaranteed by callback assignment)
- groups.ts: fix operator precedence with ?? (wrap +attrs in parens), fix groupId type
- messages-recv.ts: extract messageKey.id to local const with fallback
- socket.ts: revert onClose! (guaranteed by synchronous callback assignment)
- event-buffer.ts: add 'notify' fallback for MessageUpsertType
- messages.ts: add filePath const after null guard, fix contextInfo type assertion
- noise-handler.ts: restore array index ! (guaranteed by length check)

Build now compiles with zero new errors.

https://claude.ai/code/session_01E2cfX1N3sJgCJBTvzGazSG
This commit is contained in:
Claude
2026-02-09 01:02:13 +00:00
parent d903c57476
commit 6e394bd540
7 changed files with 20 additions and 21 deletions
+1 -1
View File
@@ -1265,7 +1265,7 @@ function consolidateEvents(data: BufferedEventData) {
const messageUpsertList = Object.values(data.messageUpserts)
if (messageUpsertList.length) {
const type = messageUpsertList[0]?.type
const type = messageUpsertList[0]?.type ?? 'notify'
map['messages.upsert'] = {
messages: messageUpsertList.map(m => m.message),
type
+6 -4
View File
@@ -264,9 +264,11 @@ export const prepareWAMessageMedia = async (
throw new Boom('Missing file path for processing')
}
const filePath = originalFilePath!
if (requiresThumbnailComputation) {
const { thumbnail, originalImageDimensions } = await generateThumbnail(
originalFilePath,
filePath,
mediaType as 'image' | 'video',
options
)
@@ -281,12 +283,12 @@ export const prepareWAMessageMedia = async (
}
if (requiresDurationComputation) {
uploadData.seconds = await getAudioDuration(originalFilePath)
uploadData.seconds = await getAudioDuration(filePath)
logger?.debug('computed audio duration')
}
if (requiresWaveformProcessing) {
uploadData.waveform = await getAudioWaveform(originalFilePath, logger)
uploadData.waveform = await getAudioWaveform(filePath, logger)
logger?.debug('processed waveform')
}
@@ -1767,7 +1769,7 @@ export const generateWAMessageFromContent = (
const innerContent = innerMessage[key as Exclude<keyof proto.IMessage, 'conversation'>]
const contextInfo: proto.IContextInfo =
(innerContent && 'contextInfo' in innerContent && innerMessage[key as Exclude<keyof proto.IMessage, 'conversation'>]?.contextInfo) || {}
(innerContent && typeof innerContent === 'object' && 'contextInfo' in innerContent && (innerContent as Record<string, unknown>).contextInfo as proto.IContextInfo) || {}
contextInfo.participant = jidNormalizedUser(participant ?? '')
contextInfo.stanzaId = quoted.key.id
contextInfo.quotedMessage = quotedMsg
+1 -1
View File
@@ -150,7 +150,7 @@ export const makeNoiseHandler = ({
while (true) {
if (inBytes.length < 3) return
size = (inBytes[0] << 16) | (inBytes[1] << 8) | inBytes[2]
size = (inBytes[0]! << 16) | (inBytes[1]! << 8) | inBytes[2]!
if (inBytes.length < size + 3) return