Skip to content

Conversation

@sakari
Copy link
Collaborator

@sakari sakari commented Dec 12, 2025

Remove dependency to typescript AST. The typescript AST is not very stable API and causes us to have to change oats for new ts versions. Instead we now generate the code using template strings. A bit less type safety but a lot less prone to breaking with ts versions.

This should not change the behaviour or the semantics of the generated code -- just generation and possibly whitespace. Note that the integration tests in /test have not been changed.

This pr also refactors type generation code to be more testable

For one major user of the code generation the resulting code is the same modulo newlines and trailing commas and handling of incorrectly defined objects schemas. That and all the integration tests passing give some confidence that the generation works.

todo

  • use string literals for generating types
  • release canary and create some test builds in projects using oats to see if tests pass in actual use

"lodash": "^4.17.20",
"openapi3-ts": "^3.0.0"
"openapi3-ts": "^3.0.0",
"prettier": "^2.8.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we use prettier internally to print typescript code

@sakari sakari requested a review from lautis December 15, 2025 08:48
Copy link
Member

@lautis lautis left a comment

Choose a reason for hiding this comment

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

Agree with the reasoning – at least currently the AST approach has been a bit flaky and would expect even more changes with TypeScript 7. Having prettier 2 as runtime dependency is a bit annoying, but as discussed in Slack, we can fix that relatively easily.

@sakari sakari merged commit a4390b6 into master Dec 16, 2025
1 check passed
@sakari sakari deleted the remove-typescript-ast-dependency branch December 16, 2025 06:57
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.

2 participants