-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: .merge
results in Typescript error
#57
Conversation
Hello, I will see that when I got some time. Thanks for your contribution. 🙂 |
@@ -6,7 +6,7 @@ import { zodSchemaIsAsync } from "./utils/zodSchemaIsAsync"; | |||
|
|||
declare module "zod" { | |||
interface ZodType { | |||
accelerator?: ZodAcceleratorParser<this>; | |||
accelerator?: ZodAcceleratorParser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declare module "zod" {
interface ZodType<
Output = any,
Def extends zod.ZodTypeDef = zod.ZodTypeDef,
Input = Output,
> {
accelerator?: ZodAcceleratorParser<
ZodType<Output, Def, Input>
>;
}
}
This solution seems the best to me, it allows you to save a typing but not have any problems ts(2589).
@@ -180,4 +180,63 @@ describe("object type", () => { | |||
]); | |||
} | |||
}); | |||
|
|||
it("input merged object", () => { | |||
const schema = zod.object({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const schemaA = zod.object({
test1: zod.string(),
});
const schemaB = zod.object({
test2: zod.number(),
});
const schema = schemaA.merge(schemaB).strict();
This statement is a little better, it is more readable. (You would tell me on one hand, my tests are not very beautiful ^^')
I made the decision to apply the fix to avoid dragging things out. Here's the PR :#60 , thanks again for your contribution! |
thats great, thanks! |
The following code:
caused
Type instantiation is excessively deep and possibly infinite.ts(2589)
:Note: I was unfortunately unable to understand
CONTRIBUTING.md
because it's in French. I also was also unable to make the pre-commit hook work: