diff --git a/src/ZodSchemaClass.ts b/src/ZodSchemaClass.ts index 765d5c5..53a6cdc 100644 --- a/src/ZodSchemaClass.ts +++ b/src/ZodSchemaClass.ts @@ -1,9 +1,9 @@ import { expression } from "@thilawyn/traitify-ts" import { NoInfer } from "effect/Types" -import { AbstractClass, Class } from "type-fest" +import { AbstractClass } from "type-fest" import { z } from "zod" import { InstantiableZodSchemaObject } from "./traits/InstantiableZodSchemaObject" -import { StaticMembers } from "./util" +import { Extend, StaticMembers } from "./util" export function ZodSchemaClassOf< @@ -36,11 +36,19 @@ export function ZodSchemaClassOf< .expresses(InstantiableZodSchemaObject) .build() - return exp.extends as Class< - InstanceType & Values, + return exp.extends as AbstractClass< + Extend<[ + InstanceType, + InstanceType, + Values, + ]>, + ConstructorParameters > & - StaticMembers + Extend<[ + StaticMembers, + StaticMembers, + ]> } diff --git a/src/util/inheritance.ts b/src/util/extend.ts similarity index 83% rename from src/util/inheritance.ts rename to src/util/extend.ts index a179d78..21aa4ab 100644 --- a/src/util/inheritance.ts +++ b/src/util/extend.ts @@ -9,10 +9,10 @@ export type CommonKeys = Extract * Merges an inheritance tree defined by an array of types, considering overrides. * @template T - An array of types representing the inheritance tree. */ -export type MergeInheritanceTree = ( +export type Extend = ( T extends [infer Super, infer Self, ...infer Rest] ? Pick> extends Pick> - ? MergeInheritanceTree<[ + ? Extend<[ Omit> & Self, ...Rest, ]> @@ -26,10 +26,10 @@ export type MergeInheritanceTree = ( * Merges an inheritance tree defined by an array of types without allowing overrides. * @template T - An array of types representing the inheritance tree. */ -export type MergeInheritanceTreeWithoutOverriding = ( +export type ExtendWithoutOverriding = ( T extends [infer Super, infer Self, ...infer Rest] ? Pick> extends Pick> - ? MergeInheritanceTreeWithoutOverriding<[ + ? ExtendWithoutOverriding<[ Super & Self, ...Rest, ]> diff --git a/src/util/index.ts b/src/util/index.ts index f7d0c08..7bc5968 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -1,4 +1,4 @@ export * from "./class" export * from "./effect" -export * from "./inheritance" +export * from "./extend" export * from "./misc"