fix(album): resolve TypeScript strict array access errors

Fix TS2345 errors where array element access (medias[i]) was inferred as
`AlbumMediaItem | undefined` instead of `AlbumMediaItem`.

Changes:
- Add non-null assertion (!) after array access in for loops
- Add explicit cast to AnyMessageContent for hasNonNullishProperty calls

The non-null assertion is safe here because we iterate with `i < medias.length`,
guaranteeing the index is valid.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Renato Alcara
2026-01-23 15:48:09 -03:00
parent 688739239a
commit d95b2236c0
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -496,10 +496,10 @@ export const generateWAMessageContent = async (
let expectedVideoCount = 0
for (let i = 0; i < medias.length; i++) {
const media = medias[i]
if (hasNonNullishProperty(media, 'image')) {
const media = medias[i]!
if (hasNonNullishProperty(media as AnyMessageContent, 'image')) {
expectedImageCount++
} else if (hasNonNullishProperty(media, 'video')) {
} else if (hasNonNullishProperty(media as AnyMessageContent, 'video')) {
expectedVideoCount++
} else {
throw new Boom(`Album media at index ${i} must have 'image' or 'video' property`, { statusCode: 400 })