Skip to content

Conversation

@etraut-openai
Copy link
Collaborator

@etraut-openai etraut-openai commented Oct 29, 2025

This PR addresses a current hole in the TypeScript code generation for the API server protocol. Fields that are marked as "Optional<>" in the Rust code are serialized such that the value is omitted when it is deserialized — appearing as undefined, but the TS type indicates (incorrectly) that it is always defined but possibly null. This can lead to subtle errors that the TypeScript compiler doesn't catch. The fix is to include the #[ts(optional_fields = nullable)] macro for all protocol structs that contain one or more Optional<> fields.

This PR also includes a new test that validates that all TS protocol code containing "| null" in its type is marked optional ("?") to catch cases where #[ts(optional_fields = nullable)] is omitted.

…l fields

Also includes a test that validates that all ts protocol code that contains "| null" is marked optional ("?") to catch cases where "#[ts(optional_fields = nullable)]" is omitted
@etraut-openai etraut-openai marked this pull request as ready for review October 29, 2025 02:42
Copy link
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's get this straightforward solution in ASAP and then see if we can do something fancier in the near future!

@etraut-openai etraut-openai merged commit 069a38a into main Oct 29, 2025
25 of 45 checks passed
@etraut-openai etraut-openai deleted the etraut/ts-optional branch October 29, 2025 19:09
@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants