From 7eb3842c9d3d2688e179321bd9cbff43292f93f8 Mon Sep 17 00:00:00 2001 From: miunau Date: Mon, 18 Aug 2025 12:54:47 +0200 Subject: [PATCH 1/2] fix: export types, add .js to imports for nodenext compatibility --- lib/dezerialize.ts | 6 +++--- lib/index.test.ts | 6 +++--- lib/index.ts | 10 +++++----- lib/infer.ts | 4 +--- lib/zerialize.ts | 6 +++--- lib/zod-types.ts | 12 ++++++------ 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/lib/dezerialize.ts b/lib/dezerialize.ts index 9a59665..0ba9617 100644 --- a/lib/dezerialize.ts +++ b/lib/dezerialize.ts @@ -35,11 +35,11 @@ import { SzVoid, SzRef, NUMBER_FORMATS, -} from "./types"; +} from "./types.js"; -import { ZodTypes } from "./zod-types"; +import { ZodTypes } from "./zod-types.js"; -type DezerializerOptions = { +export type DezerializerOptions = { errors?: { [key: string]: z.core.$ZodErrorMap; }; diff --git a/lib/index.test.ts b/lib/index.test.ts index 18147e2..841033e 100644 --- a/lib/index.test.ts +++ b/lib/index.test.ts @@ -1,10 +1,10 @@ import fs from "fs"; import { expect, test } from "vitest"; import { z } from "zod"; -import { SzCatch, SzEnum } from "./types"; -import { ZodTypes } from "./zod-types"; +import { SzCatch, SzEnum } from "./types.js"; +import { ZodTypes } from "./zod-types.js"; -import { dezerialize, SzType, zerialize, Zerialize } from "./index"; +import { dezerialize, SzType, zerialize, Zerialize } from "./index.js"; const zodexSchemaJSON = JSON.parse( fs.readFileSync("./schema.zodex.json", "utf-8"), diff --git a/lib/index.ts b/lib/index.ts index 22d9b69..0eb2242 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,11 +1,11 @@ -import { SzType } from "./types"; +import { SzType } from "./types.js"; -export * from "./dezerialize"; -export * from "./zerialize"; +export * from "./dezerialize.js"; +export * from "./zerialize.js"; -export * from "./types"; +export * from "./types.js"; -type KeysOfUnion = T extends T ? keyof T : never; +export type KeysOfUnion = T extends T ? keyof T : never; export type SzPropertyKeysOf = KeysOfUnion< Extract["properties"] >; diff --git a/lib/infer.ts b/lib/infer.ts index 7593771..79dceb0 100644 --- a/lib/infer.ts +++ b/lib/infer.ts @@ -1,5 +1,3 @@ -import { RequiredKeysOf, OptionalKeysOf } from "type-fest"; - import { SzType, SzOptional, @@ -16,7 +14,7 @@ import { SzEnum, SzPromise, // SzRef, -} from "./types"; +} from "./types.js"; type PrimitiveTypes = { string: string; diff --git a/lib/zerialize.ts b/lib/zerialize.ts index 402a127..4cdc607 100644 --- a/lib/zerialize.ts +++ b/lib/zerialize.ts @@ -30,8 +30,8 @@ import { SzSymbol, SzExtras, SzKey, -} from "./types"; -import { ZodTypes, ZTypeName } from "./zod-types"; +} from "./types.js"; +import { ZodTypes, ZTypeName } from "./zod-types.js"; export const PRIMITIVES = { ZodString: "string", @@ -50,7 +50,7 @@ export const PRIMITIVES = { } as const satisfies Readonly>>; export type PrimitiveMap = typeof PRIMITIVES; -type IsZodPrimitive = +export type IsZodPrimitive = ZTypeName extends keyof PrimitiveMap ? any : never; // Helper type to extract SomeType from Zod 4 diff --git a/lib/zod-types.ts b/lib/zod-types.ts index 88d3c7c..564a301 100644 --- a/lib/zod-types.ts +++ b/lib/zod-types.ts @@ -1,9 +1,9 @@ import { z } from "zod"; // Helper type to extract SomeType from Zod 4 -type SomeType = z.core.SomeType; +export type SomeType = z.core.SomeType; -type Modifiers = +export type Modifiers = | z.ZodOptional | z.ZodNullable | z.ZodDefault @@ -13,7 +13,7 @@ type Modifiers = | z.ZodLazy | z.ZodReadonly; -type Primitives = +export type Primitives = | z.ZodString | z.ZodCoercedString | z.ZodNumber @@ -33,17 +33,17 @@ type Primitives = | z.ZodVoid | z.ZodSymbol; -type ListCollections = +export type ListCollections = | z.ZodTuple | z.ZodSet | z.ZodArray; -type KVCollections = +export type KVCollections = | z.ZodObject | z.ZodRecord | z.ZodMap; -type ADTs = +export type ADTs = | z.ZodUnion | z.ZodDiscriminatedUnion | z.ZodIntersection From c0773239fc9514fd516083ee45cf7fbbc43fb8de Mon Sep 17 00:00:00 2001 From: miunau Date: Mon, 18 Aug 2025 19:51:27 +0200 Subject: [PATCH 2/2] fix: also export zod-types.js --- lib/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/index.ts b/lib/index.ts index 0eb2242..b349c2f 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -4,6 +4,7 @@ export * from "./dezerialize.js"; export * from "./zerialize.js"; export * from "./types.js"; +export * from "./zod-types.js"; export type KeysOfUnion = T extends T ? keyof T : never; export type SzPropertyKeysOf = KeysOfUnion<