Remove zod inference and use explicit TypeScript types #612
+1,214
−674
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.
Fixes #119, wherein more context on why these types are bad for users, but in short, this makes things readable by humans, and also probably improves TS perf and even in some cases correctness.
To do so, I replaced all the
zod.infer
stuff, which is a mess as described in the issue, with explicit types. I moved the JSDoc to the new types, since that's where humans will read now -- and indeed they will actually be able to read! I added return types explicitly to the client, there may be other places to do this as well which I'm happy to add or can be added over time. Type assertions ensure the new types match the schemas. (There are no runtime changes.)This is a bit more annoying to maintain, of course -- the ideal would be to generate the schemas from the types and I assume there are packages to do so although I haven't explored the Zod universe lately. But in practice, Claude did all the work, so he can probably keep doing it as the types evolve.
🤖 Generated with Claude Code
Breaking Changes
This may fail users' TS builds when they upgrade, if the bad types were hiding bugs (as, in our codebase, they were). Those are already bugs for them, just ones TS couldn't catch. There are no runtime changes.
Types of changes
Checklist