From d778d57e4c13ef761400d4e151125d8a701ea6eb Mon Sep 17 00:00:00 2001 From: Franco Zalamena Date: Tue, 7 Apr 2026 16:10:48 +0100 Subject: [PATCH] fix: return proper Date objects for createdAt/expiresAt in fromDict The previous implementation used setUTCMilliseconds() which returns a number, not a Date object. This caused runtime type mismatches and crashes when consumers called Date methods on these fields. Also removes the @ts-ignore workaround and provides a default value for priorityLevel to fix the exposed type error. Fixes #581 Co-Authored-By: Claude Opus 4.6 --- src/inApp/classes/IterableInAppMessage.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/inApp/classes/IterableInAppMessage.ts b/src/inApp/classes/IterableInAppMessage.ts index c77b08e63..d06513529 100644 --- a/src/inApp/classes/IterableInAppMessage.ts +++ b/src/inApp/classes/IterableInAppMessage.ts @@ -175,15 +175,13 @@ export class IterableInAppMessage { const campaignId = dict.campaignId; const trigger = IterableInAppTrigger.fromDict(dict.trigger); - let createdAt = dict.createdAt; - if (createdAt) { - const dateObject = new Date(0); - createdAt = dateObject.setUTCMilliseconds(createdAt); + let createdAt: Date | undefined; + if (dict.createdAt) { + createdAt = new Date(dict.createdAt); } - let expiresAt = dict.expiresAt; - if (expiresAt) { - const dateObject = new Date(0); - expiresAt = dateObject.setUTCMilliseconds(expiresAt); + let expiresAt: Date | undefined; + if (dict.expiresAt) { + expiresAt = new Date(dict.expiresAt); } const saveToInbox = IterableUtil.readBoolean(dict, 'saveToInbox'); const inboxMetadataDict = dict.inboxMetadata; @@ -196,16 +194,12 @@ export class IterableInAppMessage { const customPayload = dict.customPayload; const read = IterableUtil.readBoolean(dict, 'read'); - const priorityLevel = dict.priorityLevel; + const priorityLevel = dict.priorityLevel ?? 0; return new IterableInAppMessage( messageId, campaignId, trigger, - // MOB-10426: Speak to the team about `IterableInAppMessage` requiring a date - // object, but being passed a number in this case - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore createdAt, expiresAt, saveToInbox,