Fix: [ms] encoded duration default values were being encoded with the wrong format. - #11731
Open
Gerardo Lecaros (glecaros) wants to merge 1 commit into
Open
Fix: [ms] encoded duration default values were being encoded with the wrong format.#11731Gerardo Lecaros (glecaros) wants to merge 1 commit into
Gerardo Lecaros (glecaros) wants to merge 1 commit into
Conversation
…ly encode the durations as the proper type.
Gerardo Lecaros (glecaros)
force-pushed
the
glecaros/milliseconds
branch
from
August 19, 2026 19:07
338e2d2 to
4a93627
Compare
Copilot started reviewing on behalf of
Gerardo Lecaros (glecaros)
August 19, 2026 19:07
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes TypeSpec compiler example serialization for duration values encoded via @encode("milliseconds", ...), ensuring they serialize as numeric millisecond values (rather than ISO 8601 strings), aligned with the intended encoding semantics.
Changes:
- Added
"milliseconds"handling to thedurationscalar serializer to emitduration.total({ unit: "milliseconds" })(floored for integer target scalars). - Added unit tests covering both integer and floating-point millisecond encodings.
- Added a Chronus changelog entry documenting the fix for
@typespec/compiler.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/compiler/src/lib/examples.ts | Implements millisecond numeric serialization for encoded duration examples. |
| packages/compiler/test/decorators/examples.test.ts | Adds regression tests validating millisecond encoding outputs for int32/float32. |
| .chronus/changes/fix-duration-milliseconds-example-serialization-2026-8-19-18-30-0.md | Documents the fix in the compiler changelog stream. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
All changed packages have been documented.
Show changes
|
commit: |
|
You can try these changes here
|
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.
This pull request fixes an issue with how
durationexample values are serialized when using the@encode("milliseconds", ...)decorator. Previously, these values were being serialized as ISO 8601 strings instead of numeric values. The update ensures that durations are now correctly serialized as numbers representing milliseconds. The most important changes are:Bug Fix: Duration Serialization
packages/compiler/src/lib/examples.tsso that when encoding durations as"milliseconds", the output is a numeric value (integer or float, as appropriate), not an ISO 8601 string.Testing
packages/compiler/test/decorators/examples.test.tsto verify that durations encoded as milliseconds produce the correct numeric values in both integer and float formats.Documentation
.chronus/changes/fix-duration-milliseconds-example-serialization-2026-8-19-18-30-0.mddescribing the fix and its impact.