Skip to content

fix: improve typescript generator#331

Merged
jonaslagoni merged 14 commits intomainfrom
improve_typescript_generator
Mar 1, 2026
Merged

fix: improve typescript generator#331
jonaslagoni merged 14 commits intomainfrom
improve_typescript_generator

Conversation

@jonaslagoni
Copy link
Contributor

@jonaslagoni jonaslagoni commented Feb 22, 2026

Note

Medium Risk
Touches TypeScript code generation for primitives/arrays/unions and AJV schema generation/validation, which can change emitted types and runtime behavior (notably date/null handling and union schemas). Risk is mitigated by updated snapshots and added runtime fixtures, but regressions could impact downstream generated clients.

Overview
Improves the TypeScript generator by upgrading @asyncapi/modelina and extending the primitives preset to generate correct marshal/unmarshal for null schemas and date/date-time formatted strings (now producing Date objects on unmarshal).

Tightens array unmarshalling to avoid calling .unmarshal for nested arrays and union aliases, and updates validation generation to (1) accept marshalled JSON strings by JSON.parse-ing input before AJV validation and (2) sanitize root-level union schemas by omitting conflicting type: "object" when oneOf/anyOf is present.

Updates generated test snapshots/runtime outputs accordingly, including new runtime fixtures and scripts for comprehensive payload-type generation/testing, plus minor test comment cleanup.

Written by Cursor Bugbot for commit b2ef5d7. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Feb 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
the-codegen-project Ready Ready Preview, Comment Mar 1, 2026 8:15pm
the-codegen-project-mcp Ready Ready Preview, Comment Mar 1, 2026 8:15pm

@netlify
Copy link

netlify bot commented Feb 22, 2026

Deploy Preview for the-codegen-project canceled.

Name Link
🔨 Latest commit b2ef5d7
🔍 Latest deploy log https://app.netlify.com/projects/the-codegen-project/deploys/69a49dde298a680008561190

@jonaslagoni
Copy link
Contributor Author

Re: Date unmarshal bug

Acknowledged. This is a valid bug that will require fixes in two places:

  1. This repo (cli): The primitives.ts preset handles simple type aliases like FormatDate. The unmarshal needs to wrap date strings with new Date().

  2. Modelina repo: The class-based models like PetOrder and AllOfTwoTypes have unmarshal code generated by Modelina. Date conversion needs to be added there.

Tracking this for a follow-up fix that spans both repos.

- Remove 'time' format from isDateFormatModel to prevent Invalid Date
  (time strings like "14:30:00" are not valid Date constructor args)
- Exclude ConstrainedUnionModel from hasItemUnmarshal to prevent
  undefined Union.unmarshal reference for tuple arrays

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@jonaslagoni jonaslagoni merged commit f1d4db8 into main Mar 1, 2026
22 checks passed
@jonaslagoni jonaslagoni deleted the improve_typescript_generator branch March 1, 2026 20:40
@jonaslagoni
Copy link
Contributor Author

🎉 This PR is included in version 0.64.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant