fix(types): remove safe as any casts in messages.ts

fix(types): remove safe `as any` casts in messages.ts
This commit is contained in:
Renato Alcara
2026-02-08 20:08:52 -03:00
committed by GitHub
2 changed files with 7 additions and 8 deletions
+2 -3
View File
@@ -1,5 +1,5 @@
import { Boom } from '@hapi/boom'
import { exec } from 'child_process'
import { execFile } from 'child_process'
import * as Crypto from 'crypto'
import { once } from 'events'
import { createReadStream, createWriteStream, promises as fs, WriteStream } from 'fs'
@@ -127,8 +127,7 @@ const extractVideoThumb = async (
size: { width: number; height: number }
) =>
new Promise<void>((resolve, reject) => {
const cmd = `ffmpeg -ss ${time} -i ${path} -y -vf scale=${size.width}:-1 -vframes 1 -f image2 ${destPath}`
exec(cmd, err => {
execFile('ffmpeg', ['-ss', time, '-i', path, '-y', '-vf', `scale=${size.width}:-1`, '-vframes', '1', '-f', 'image2', destPath], err => {
if (err) {
reject(err)
} else {
+5 -5
View File
@@ -288,7 +288,7 @@ export const prepareWAMessageMedia = async (
logger?.debug('computed backgroundColor audio status')
}
} catch (error) {
logger?.warn({ trace: (error as any).stack }, 'failed to obtain extra info')
logger?.warn({ trace: error instanceof Error ? error.stack : String(error) }, 'failed to obtain extra info')
}
})()
]).finally(async () => {
@@ -390,8 +390,8 @@ export const hasNonNullishProperty = <K extends PropertyKey>(
typeof message === 'object' &&
message !== null &&
key in message &&
(message as any)[key] !== null &&
(message as any)[key] !== undefined
(message as Record<PropertyKey, unknown>)[key] !== null &&
(message as Record<PropertyKey, unknown>)[key] !== undefined
)
}
@@ -1153,7 +1153,7 @@ export const generateListMessageLegacy = (
}
function hasOptionalProperty<T, K extends PropertyKey>(obj: T, key: K): obj is WithKey<T, K> {
return typeof obj === 'object' && obj !== null && key in obj && (obj as any)[key] !== null
return typeof obj === 'object' && obj !== null && key in obj && (obj as Record<PropertyKey, unknown>)[key] !== null
}
export const generateWAMessageContent = async (
@@ -2034,7 +2034,7 @@ export function getAggregateResponsesInEventMessage(
}
for (const update of eventResponses || []) {
const responseType = (update as any).eventResponse || 'UNKNOWN'
const responseType = (update as unknown as { eventResponse?: string }).eventResponse || 'UNKNOWN'
if (responseType !== 'UNKNOWN' && responseMap[responseType]) {
responseMap[responseType].responders.push(getKeyAuthor(update.eventResponseMessageKey, meId))
}