Support exactOptionalPropertyTypes#1371
Merged
Merged
Conversation
Member
|
Thanks for the PR, Andrew! I'm a bit distracted by other things right now, but I'll check it out soon. |
timostamm
approved these changes
Apr 20, 2026
timostamm
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR, Andrew 🙂
I was afraid this would entail more changes in our runtime packages, but this all looks reasonable to me. I did push up a small change to toJson and fromJson, and updated the code snippets in the manual to match the new generated code.
I didn't add it to the JSON types
Agreed.
|
I don't want to sound salty. But... my original PR #1347 was closed incorrectly, then you made me open an issue to reopen that PR, and instead you just resolved the issue yourself without giving a chance to contribute. And not even co-authored-by. |
Merged
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.
Closes #1358
This PR adds support for the
exactOptionalPropertyTypesTypeScript compiler option, which is on by default intsc --initfrom Typescript 5.9 onwards. This necessitates adding| undefinedto the typing of optional fields so that they may be explicitly set to undefined, not just omitted.I've enabled the option in the compiler settings for this project to catch any issues, which meant adding a few
| undefineds to types used internally as well.I didn't add it to the JSON types because doing so means either adding
| undefinedto the fields ofJsonObject(which seems wrong when deserializing from JSON can never produce anundefinedfield) or removing the constraint thatMessageJsonType extends JsonValue(which seems wrong because the JSON types are JSON values).