-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Project] Issue while adding more tests for validateGeneratedType #186
Comments
Hi @tvillaren, I had a quick look at the simplified example and I saw that the schema is incorrect. diff --git a/src/core/validateGeneratedTypes.test.ts b/src/core/validateGeneratedTypes.test.ts
index 78fe5ea..bceb9c2 100644
--- a/src/core/validateGeneratedTypes.test.ts
+++ b/src/core/validateGeneratedTypes.test.ts
@@ -221,7 +221,7 @@ describe("validateGeneratedTypes", () => {
import { z } from "zod";
export const citizenSchema = z.object({
- heroAliases: z.union(z.string(), z.number())
+ heroAliases: z.union([z.string(), z.number()])
});
`,
relativePath: "source.zod.ts", I did not check the other code, so it can be that the reproducer example was not representative for the real issue you are experiencing. |
🤦 So actually, the issue is different and only appears on my branch, which introduces import handling, when we reference imported types/interfaces (which are transformed to I spent some more time digging, and it appears the issue has nothing to do with my rebase to the last version of Trying to reproduce colinhacks/zod#2203 with
|
Yeah, Maybe something to look at: https://www.totaltypescript.com/how-to-test-your-types |
Yes, I was looking at alternatives. Found the type-testing library on Advent of Typescript |
Isn't |
Closing, implemented some more cases to fixOptionalAny |
Hey @fabien0102,
I'm creating an issue for something which doesn't seem like a bug, at least wasn't able to reproduce in a "real-life" project but some of the tests I'm adding (for #135) now fail after a rebase on
main
(post-release of 3.4.1).Context
A couple of month ago, I raised #140 because some validations were failing on my project due to a bug in
zod
.I had similar validation fail after working on a built version of branch introducing import handling so decided to add some tests (74b10b3) to cover specific identifier references triggering optional any.
👉 Those tests don't pass anymore since I rebased the branch
👉 They still pass on another branch (https://github.com/tvillaren/ts-to-zod/tree/feat-handle-zod-imports) which I haven't rebased
I created a simple branch from the current
main#HEAD
with a simple not passing test (simple union in an object): https://github.com/tvillaren/ts-to-zod/actions/runs/7062596244/job/19226755896I'm a bit lost, tried different things including fiddling with the fixOptionalAny file to add more edge cases but outputting the actual types from the
vfs
(acda151) gives me some discrepancies in type inference.I'm starting to thing the Typescript inference doesn't work the same way in VFS that on my system (I checked version of TS passed and they are the same).
If you have any idea (or @schiller-manuel as you seem to have updated this project quite a lot recently 😉), I'm all hear!
(I'm running those on a Mac)
Thanks!
The text was updated successfully, but these errors were encountered: