fix(api): Activity.timestamp should be string instead of Date (type only)#571
Open
heyitsaamir wants to merge 2 commits into
Open
fix(api): Activity.timestamp should be string instead of Date (type only)#571heyitsaamir wants to merge 2 commits into
heyitsaamir wants to merge 2 commits into
Conversation
The Bot Framework Activity protocol sends these as ISO-8601 strings over JSON (as the existing doc comments already say). Inbound activities are parsed by express.json() with no reviver and Activity.from() is just Object.assign — so at runtime these fields are strings, not Date objects. The Date type was a lie; calling activity.timestamp.toISOString() in a handler would crash. The withTimestamp/withLocalTimestamp builders still accept Date for ergonomics and normalize via toISOString(), so existing call sites keep working.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects the public typings for Activity.timestamp and Activity.localTimestamp in @microsoft/teams.api to reflect actual runtime behavior: these fields are ISO-8601 strings on inbound activities, not Date objects. It also updates the fluent builder methods to keep accepting Date inputs while normalizing them to ISO strings to avoid breaking common construction patterns.
Changes:
- Change
IActivity.timestamp/localTimestampandActivity.timestamp/localTimestampfromDatetostring. - Update
withTimestampandwithLocalTimestampto acceptDate | string, convertingDateinputs totoISOString().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rido-min
reviewed
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Activity.timestampwas lying about being aDate. It's a string. Always was. The doc comment literally says "expressed in ISO-8601 format" two lines above the: Dateannotation 🙃Inbound activities go through
express.json()(no reviver), andActivity.from()is justObject.assign— nothing ever turns it into aDate. Soactivity.timestamp.toISOString()in a handler? Crash.Fix: type
timestampandlocalTimestampasstring.Also removing
withTimestamp()andwithLocalTimestamp()because timestamps set on outgoing bot activities are ignored by the chat service, so those builder helpers were a bit of a footgun/no-op.