0.1.2 #3
@@ -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<typeof exp.extends> & Values,
|
||||
return exp.extends as AbstractClass<
|
||||
Extend<[
|
||||
InstanceType<Superclass>,
|
||||
InstanceType<typeof exp.extends>,
|
||||
Values,
|
||||
]>,
|
||||
|
||||
ConstructorParameters<typeof exp.extends>
|
||||
> &
|
||||
StaticMembers<typeof exp.extends>
|
||||
Extend<[
|
||||
StaticMembers<Superclass>,
|
||||
StaticMembers<typeof exp.extends>,
|
||||
]>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ export type CommonKeys<A, B> = Extract<keyof A, keyof B>
|
||||
* 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<T extends readonly any[]> = (
|
||||
export type Extend<T extends readonly any[]> = (
|
||||
T extends [infer Super, infer Self, ...infer Rest]
|
||||
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
||||
? MergeInheritanceTree<[
|
||||
? Extend<[
|
||||
Omit<Super, CommonKeys<Self, Super>> & Self,
|
||||
...Rest,
|
||||
]>
|
||||
@@ -26,10 +26,10 @@ export type MergeInheritanceTree<T extends readonly any[]> = (
|
||||
* 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<T extends readonly any[]> = (
|
||||
export type ExtendWithoutOverriding<T extends readonly any[]> = (
|
||||
T extends [infer Super, infer Self, ...infer Rest]
|
||||
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
||||
? MergeInheritanceTreeWithoutOverriding<[
|
||||
? ExtendWithoutOverriding<[
|
||||
Super & Self,
|
||||
...Rest,
|
||||
]>
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from "./class"
|
||||
export * from "./effect"
|
||||
export * from "./inheritance"
|
||||
export * from "./extend"
|
||||
export * from "./misc"
|
||||
|
||||
Reference in New Issue
Block a user