Skip to content

Commit

Permalink
Remove createParams cascade from .array() (#3530)
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanBehrends authored Dec 10, 2024
1 parent 6407bed commit 3755146
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions deno/lib/__tests__/description.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ test("description should carry over to chained schemas", () => {
description
);
});

test("description should not carry over to chained array schema", () => {
const schema = z.string().describe(description)

expect(schema.description).toEqual(description);
expect(schema.array().description).toEqual(undefined);
expect(z.array(schema).description).toEqual(undefined);
})
2 changes: 1 addition & 1 deletion deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export abstract class ZodType<
return this.nullable().optional();
}
array(): ZodArray<this> {
return ZodArray.create(this, this._def);
return ZodArray.create(this);
}
promise(): ZodPromise<this> {
return ZodPromise.create(this, this._def);
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/description.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ test("description should carry over to chained schemas", () => {
description
);
});

test("description should not carry over to chained array schema", () => {
const schema = z.string().describe(description)

expect(schema.description).toEqual(description);
expect(schema.array().description).toEqual(undefined);
expect(z.array(schema).description).toEqual(undefined);
})
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export abstract class ZodType<
return this.nullable().optional();
}
array(): ZodArray<this> {
return ZodArray.create(this, this._def);
return ZodArray.create(this);
}
promise(): ZodPromise<this> {
return ZodPromise.create(this, this._def);
Expand Down

0 comments on commit 3755146

Please sign in to comment.