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:
@@ -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 })
|
||||
|
||||
Reference in New Issue
Block a user