Skip to content

Fix handle nullable types in typescript generated client#39

Merged
sas1024 merged 5 commits into
vmkteam:masterfrom
pont1s:fix/handle-nullable-types-in-generated-code
Jun 16, 2026
Merged

Fix handle nullable types in typescript generated client#39
sas1024 merged 5 commits into
vmkteam:masterfrom
pont1s:fix/handle-nullable-types-in-generated-code

Conversation

@pont1s

@pont1s pont1s commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

The generated TypeScript client currently declares nullable fields (Go pointers/optional values) as field?: T, which in TS means T or omitted from object, as if the field were "cut out" from the JSON response. This does not correspond to the behavior of the real API: the zenrpc/Go server serializes nil as "field": null (the field is present with a null value), rather than omitting them.

  • | null reflects the real shape of the response
  • ? is kept for the request side — the server accepts requests with the field omitted

Copilot AI review requested due to automatic review settings June 4, 2026 09:13
@pont1s pont1s changed the title fix(typescript): handle nullable types in generated code Fix handle nullable types in generated code Jun 4, 2026
@pont1s pont1s changed the title Fix handle nullable types in generated code Fix handle nullable types in typescript generated client Jun 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the TypeScript codegen to model “optional” schema fields as null-able (via | null) instead of optional properties (?), and adjusts generated class defaults accordingly.

Changes:

  • Removes ? optional markers from generated TS interfaces and classes.
  • Renames the generated field metadata from Optional to Nullable and appends | null to nullable field types.
  • Updates TS golden/testdata outputs to reflect | null and null! defaults.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
typescript/typescript_template.go Stops emitting optional (?) properties in generated interfaces/classes.
typescript/typescript_client.go Reinterprets “optional” as “nullable”, appends `
typescript/testdata/catalogue_with_types_only.ts Updates golden output: optional child becomes `IGroup
typescript/testdata/catalogue_with_classes.ts Updates golden output: uses null! for non-nullable fields and `
typescript/testdata/catalogue_client.ts Updates golden output: optional child becomes `IGroup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread typescript/typescript_client.go Outdated
Comment on lines +150 to +152
if result == "null" && !t.Nullable {
result = "null!"
}
Comment thread typescript/typescript_template.go Outdated
Comment thread typescript/typescript_template.go Outdated
Comment thread typescript/typescript_client.go
Comment thread typescript/typescript_client.go
Comment thread typescript/typescript_client.go Outdated
@sas1024 sas1024 merged commit 5821c60 into vmkteam:master Jun 16, 2026
1 check passed
@pont1s pont1s deleted the fix/handle-nullable-types-in-generated-code branch June 16, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants