Skip to content

Commit

Permalink
Remove source map
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McDonnell committed Mar 2, 2022
1 parent 6cadd62 commit eab3bd2
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 29 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,8 @@ interface Category {
subcategories: Category[];
}

// cast to z.ZodSchema<Category>
const Category: z.ZodSchema<Category> = z.lazy(() =>
// cast to z.ZodType<Category>
const Category: z.ZodType<Category> = z.lazy(() =>
z.object({
name: z.string(),
subcategories: z.array(Category),
Expand Down Expand Up @@ -1116,7 +1116,7 @@ interface Category extends z.infer<typeof BaseCategory> {
// merge the base schema with
// a new Zod schema containing relations
const Category: z.ZodSchema<Category> = BaseCategory.merge(
const Category: z.ZodType<Category> = BaseCategory.merge(
z.object({
subcategories: z.lazy(() => z.array(Category)),
})
Expand All @@ -1131,7 +1131,7 @@ If you want to validate any JSON value, you can use the snippet below.
type Literal = boolean | null | number | string;
type Json = Literal | { [key: string]: Json } | Json[];
const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
const jsonSchema: z.ZodType<Json> = z.lazy(() =>
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
);

Expand Down
8 changes: 4 additions & 4 deletions deno/lib/__tests__/recursive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const testCategory: Category = {
};

test("recursion with z.late.object", () => {
const Category: z.Schema<Category> = z.late.object(() => ({
const Category: z.ZodType<Category> = z.late.object(() => ({
name: z.string(),
subcategories: z.array(Category),
}));
Category.parse(testCategory);
});

test("recursion with z.lazy", () => {
const Category: z.Schema<Category> = z.lazy(() =>
const Category: z.ZodType<Category> = z.lazy(() =>
z.object({
name: z.string(),
subcategories: z.array(Category),
Expand Down Expand Up @@ -130,7 +130,7 @@ test("schema getter", () => {
// subcategories: Category[];
// }

// const Category: z.Schema<Category> = z.late.object(() => ({
// const Category: z.ZodType<Category> = z.late.object(() => ({
// name: z.string(),
// subcategories: z.array(Category),
// }));
Expand All @@ -151,7 +151,7 @@ test("schema getter", () => {

// type Category = BaseCategory & { subcategories: Category[] };

// const Category: z.Schema<Category> = z.late
// const Category: z.ZodType<Category> = z.late
// .object(() => ({
// subcategories: z.array(Category),
// }))
Expand Down
11 changes: 6 additions & 5 deletions deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1646,14 +1646,15 @@ export class ZodObject<
merging: Incoming
): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
ZodObject<extendShape<T, Incoming["_shape"]>, UnknownKeys, Catchall> {
const mergedShape = objectUtil.mergeShapes(
this._def.shape(),
merging._def.shape()
);
// const mergedShape = objectUtil.mergeShapes(
// this._def.shape(),
// merging._def.shape()
// );
const merged: any = new ZodObject({
unknownKeys: merging._def.unknownKeys,
catchall: merging._def.catchall,
shape: () => mergedShape,
shape: () =>
objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
typeName: ZodFirstPartyTypeKind.ZodObject,
}) as any;
return merged;
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export default [
{
file: "lib/index.mjs",
format: "es",
sourcemap: true,
sourcemap: false,
},
],
plugins: [
typescript({
tsconfig: "tsconfig.esm.json",
sourceMap: true,
sourceMap: false,
}),
uglify(),
],
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/recursive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ const testCategory: Category = {
};

test("recursion with z.late.object", () => {
const Category: z.Schema<Category> = z.late.object(() => ({
const Category: z.ZodType<Category> = z.late.object(() => ({
name: z.string(),
subcategories: z.array(Category),
}));
Category.parse(testCategory);
});

test("recursion with z.lazy", () => {
const Category: z.Schema<Category> = z.lazy(() =>
const Category: z.ZodType<Category> = z.lazy(() =>
z.object({
name: z.string(),
subcategories: z.array(Category),
Expand Down Expand Up @@ -129,7 +129,7 @@ test("schema getter", () => {
// subcategories: Category[];
// }

// const Category: z.Schema<Category> = z.late.object(() => ({
// const Category: z.ZodType<Category> = z.late.object(() => ({
// name: z.string(),
// subcategories: z.array(Category),
// }));
Expand All @@ -150,7 +150,7 @@ test("schema getter", () => {

// type Category = BaseCategory & { subcategories: Category[] };

// const Category: z.Schema<Category> = z.late
// const Category: z.ZodType<Category> = z.late
// .object(() => ({
// subcategories: z.array(Category),
// }))
Expand Down
11 changes: 6 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1646,14 +1646,15 @@ export class ZodObject<
merging: Incoming
): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
ZodObject<extendShape<T, Incoming["_shape"]>, UnknownKeys, Catchall> {
const mergedShape = objectUtil.mergeShapes(
this._def.shape(),
merging._def.shape()
);
// const mergedShape = objectUtil.mergeShapes(
// this._def.shape(),
// merging._def.shape()
// );
const merged: any = new ZodObject({
unknownKeys: merging._def.unknownKeys,
catchall: merging._def.catchall,
shape: () => mergedShape,
shape: () =>
objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
typeName: ZodFirstPartyTypeKind.ZodObject,
}) as any;
return merged;
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"module": "commonjs",
"outDir": "lib",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"declarationMap": false,
"sourceMap": false,
},
"exclude": [
"./src/**/__tests__",
"./src/playground.ts"
]
}
}
4 changes: 2 additions & 2 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
// "outDir": "./lib/esm",
"declaration": false,
"declarationMap": false,
"sourceMap": true,
"sourceMap": false,
},
"exclude": [
"./src/**/__tests__",
"./src/playground.ts"
]
}
}

0 comments on commit eab3bd2

Please sign in to comment.