Azure / Azure/typespec-azure

[typespec-ts] Serialization/deserialization refinements (additional properties, dates, error/body split)

Open
#4,764 0 comments 0 reactions 1 assignee Claimed by @JialinHuang803 View on GitHub
emitter:typescript
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 22h
Merged PRs (30d)
156

Description

## Overview

Umbrella tracking issue for serialization/deserialization refinements in the TypeScript emitter (`@azure-tools/typespec-ts`, modular). Migrated from [Azure/autorest.typescript](https://github.com/Azure/autorest.typescript), which is being retired in favor of this repo.

## Work items

### 1. Additional properties ser/deser follow-ups
Improve ser/deser logic for both legacy and non-legacy formats:
- [ ] **Date in additional properties** — for `...Record`, the generated serializer calls `serializeRecord(item.additionalProperties ?? {})` **without** a value serializer, so `Date` values are emitted raw instead of being encoded to the wire format. (Verified locally.)
- [ ] **clientName / wireName inconsistency** in additional-properties keys/values
- [ ] **multipart/form-data with additional properties** (note: overlaps the multipart umbrella Azure/typespec-azure#4757 — de-dup there)
- [ ] **Optional `unixTimestamp` value of `0`** — for an optional `@encode("unixTimestamp")` date, the deserializer generates `!item["value"] ? item["value"] : new Date(item["value"] * 1000)`; when the value is `0`, `!0` is truthy so the raw `0` is returned instead of `new Date(0)`. (Required fields are handled correctly.)
- Migrated from Azure/autorest.typescript#3122

### 2. General ser/deser refinement
- [ ] Fix record-of-date serialization issues
- [ ] Clean up the unit tests under `packages/typespec-ts/test/modularUnit/serializeUtil`
- Migrated from Azure/autorest.typescript#2997

### 3. Separate error and body deserialization (nice-to-have)
- [ ] `_xxxDeserialize` currently bundles the error-status check and body deserialization in a single function. Extract the error-checking part into a reusable helper that can be called without consuming `result.body`, so callers (e.g. Storage `submitBatch`) don't do unnecessary work or consume the body.
- Migrated from Azure/autorest.typescript#3797

## Notes

- Test coverage is tracked as part of each fix above, not as standalone issues.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.