Skip to content

Comments

Improve Type Generation#23

Merged
maanlamp merged 15 commits intomainfrom
feature/improve-typegen
Oct 20, 2025
Merged

Improve Type Generation#23
maanlamp merged 15 commits intomainfrom
feature/improve-typegen

Conversation

@maanlamp
Copy link
Collaborator

@maanlamp maanlamp commented Jul 29, 2025

There are some important features missing from the typegen script.

Notably:

  • The typegen now creates Zod schemas and infers their type, in one go, for all routes in a given openapi spec
  • When the spec hasn't changed since last compile, it will exit early and do nothing.
  • We're no longer formatting the file, as it's automatically generated and that's not important.
  • Removed and .gitignored all generated files

Copy link
Member

@publicJorn publicJorn left a comment

Choose a reason for hiding this comment

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

I like that the generated files are now gitignored!

One issue with existing code though: I ran bun run openapi which does stuff. But previous existing code (eg. login-page.tsx) can't find the import that was previously there for the schema.

Screenshot 2025-08-21 at 12 58 54

I think this is because it is looking into components interface instead of operations.
However, it seems that operations is not in type OpenAPIV3.Document.

You know if there was an update in the spec?

publicJorn
publicJorn previously approved these changes Aug 26, 2025
@maanlamp maanlamp requested a review from publicJorn September 3, 2025 09:05
publicJorn
publicJorn previously approved these changes Oct 1, 2025
Copy link
Member

@publicJorn publicJorn left a comment

Choose a reason for hiding this comment

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

Looks mostly good to me!

Only thing I don't really like is that we check for typescript errors really late in the process (because, as we discussed vite needs to build for the .scss.d.ts files to be generated.
On larger projects, it will take some time before it will throw an error, which is a shame.

I'm not sure if there's a way around that.
I tried adding tsc --noEmit to lefthook. But this regenerates the bloody .tsbuildinfo file (which I still don't think we should put under version control, but that's a different discussion) so you will always end up with a change after your commit.

It's not blocking for this PR, but I'd like to discuss this further (maybe with a beer on friday?)

@maanlamp
Copy link
Collaborator Author

Yeah good points. I added the buildinfo to the gitignore as well.

As for the checking after building, I'm not sure if there is any way around it unless we unignore the generated files 🙃

@maanlamp maanlamp merged commit c0b2ae0 into main Oct 20, 2025
1 check passed
@maanlamp maanlamp deleted the feature/improve-typegen branch October 20, 2025 13:43
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