From 1ce249c5e6d122b152ca4bfea4287d39f3333e05 Mon Sep 17 00:00:00 2001 From: Charles Catta Date: Wed, 3 Apr 2024 15:30:32 -0400 Subject: [PATCH] fix dulicate case in merge --- deno/lib/README.md | 50 +++++++++++++++----------------- src/__tests__/firstparty.test.ts | 2 -- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/deno/lib/README.md b/deno/lib/README.md index 39cd76e73..d892d799c 100644 --- a/deno/lib/README.md +++ b/deno/lib/README.md @@ -2036,7 +2036,7 @@ const templateLiteral = z.templateLiteral(); // infers to ``. - To add string literal types to an existing template literal: ```ts - templateLiteral.literal('Hello'); // infers to `Hello`. + templateLiteral.literal("Hello"); // infers to `Hello`. templateLiteral.literal(3.14); // infers to `3.14`. ``` @@ -2048,17 +2048,17 @@ const templateLiteral = z.templateLiteral(); // infers to ``. templateLiteral.interpolated(z.string()); // infers to `${string}`. templateLiteral.interpolated(z.number()); // infers to `${number}`. templateLiteral.interpolated(z.boolean()); // infers to `true` | `false`. - templateLiteral.interpolated(z.literal('foo')); // infers to `foo`. + templateLiteral.interpolated(z.literal("foo")); // infers to `foo`. templateLiteral.interpolated(z.null()); // infers to `null`. templateLiteral.interpolated(z.undefined()); // infers to `undefined`. templateLiteral.interpolated(z.bigint()); // infers to `${bigint}`. templateLiteral.interpolated(z.any()); // infers to `${any}`. ``` - Any Zod type (or union) with an underlying type of string, number, boolean, null, - undefined or bigint can be used as an interpolated position (template literals - included!). You can use additional built-in runtime validations (refinements - excluded) in each of these types and the template literal builder will do its + Any Zod type (or union) with an underlying type of string, number, boolean, null, + undefined or bigint can be used as an interpolated position (template literals + included!). You can use additional built-in runtime validations (refinements + excluded) in each of these types and the template literal builder will do its best (within the limitations of regular expressions) to support them when parsing. ### Examples @@ -2076,22 +2076,22 @@ const url = z url.parse("https://google.com"); // passes url.parse("https://google.net"); // passes -url.parse('http://google.com'); // throws -url.parse('https://.com'); // throws -url.parse('https://google'); // throws -url.parse('https://google.'); // throws -url.parse('https://google.gov'); // throws +url.parse("http://google.com"); // throws +url.parse("https://.com"); // throws +url.parse("https://google"); // throws +url.parse("https://google."); // throws +url.parse("https://google.gov"); // throws ``` Measurement: ```ts const measurement = z.coerce - .templateLiteral() - .interpolated(z.number().finite()) - .interpolated( - z.enum(["px", "em", "rem", "vh", "vw", "vmin", "vmax"]).optional() - ); + .templateLiteral() + .interpolated(z.number().finite()) + .interpolated( + z.enum(["px", "em", "rem", "vh", "vw", "vmin", "vmax"]).optional() + ); // infers to `${number}` | `${number}px` | `${number}em` | `${number}rem` | `${number}vh` | `${number}vw` | `${number}vmin` | `${number}vmax ``` @@ -2112,9 +2112,7 @@ const connectionString = z ) .interpolated(z.string().regex(/\w+/).describe("host")) .literal(":") - .interpolated( - z.number().finite().int().positive().describe("port") - ) + .interpolated(z.number().finite().int().positive().describe("port")) .interpolated( z .templateLiteral() @@ -2132,13 +2130,13 @@ const connectionString = z ) .optional() ); - // infers to: - // | `mongodb://${string}:${number}` - // | `mongodb://${string}:${number}/${string}` - // | `mongodb://${string}:${number}/${string}?${string}` - // | `mongodb://${string}:${string}@${string}:${number}` - // | `mongodb://${string}:${string}@${string}:${number}/${string}` - // | `mongodb://${string}:${string}@${string}:${number}/${string}?${string}` +// infers to: +// | `mongodb://${string}:${number}` +// | `mongodb://${string}:${number}/${string}` +// | `mongodb://${string}:${number}/${string}?${string}` +// | `mongodb://${string}:${string}@${string}:${number}` +// | `mongodb://${string}:${string}@${string}:${number}/${string}` +// | `mongodb://${string}:${string}@${string}:${number}/${string}?${string}` ``` ## Preprocess diff --git a/src/__tests__/firstparty.test.ts b/src/__tests__/firstparty.test.ts index 3f7c71d3b..e47601cb0 100644 --- a/src/__tests__/firstparty.test.ts +++ b/src/__tests__/firstparty.test.ts @@ -83,8 +83,6 @@ test("first party switch", () => { break; case z.ZodFirstPartyTypeKind.ZodTemplateLiteral: break; - case z.ZodFirstPartyTypeKind.ZodReadonly: - break; default: util.assertNever(def); }