0.1.2 #3

Merged
Thilawyn merged 136 commits from next into master 2024-03-11 19:44:21 +01:00
3 changed files with 18 additions and 10 deletions
Showing only changes of commit ed3f8fb643 - Show all commits

View File

@@ -1,9 +1,9 @@
import { expression } from "@thilawyn/traitify-ts" import { expression } from "@thilawyn/traitify-ts"
import { NoInfer } from "effect/Types" import { NoInfer } from "effect/Types"
import { AbstractClass, Class } from "type-fest" import { AbstractClass } from "type-fest"
import { z } from "zod" import { z } from "zod"
import { InstantiableZodSchemaObject } from "./traits/InstantiableZodSchemaObject" import { InstantiableZodSchemaObject } from "./traits/InstantiableZodSchemaObject"
import { StaticMembers } from "./util" import { Extend, StaticMembers } from "./util"
export function ZodSchemaClassOf< export function ZodSchemaClassOf<
@@ -36,11 +36,19 @@ export function ZodSchemaClassOf<
.expresses(InstantiableZodSchemaObject) .expresses(InstantiableZodSchemaObject)
.build() .build()
return exp.extends as Class< return exp.extends as AbstractClass<
InstanceType<typeof exp.extends> & Values, Extend<[
InstanceType<Superclass>,
InstanceType<typeof exp.extends>,
Values,
]>,
ConstructorParameters<typeof exp.extends> ConstructorParameters<typeof exp.extends>
> & > &
StaticMembers<typeof exp.extends> Extend<[
StaticMembers<Superclass>,
StaticMembers<typeof exp.extends>,
]>
} }

View File

@@ -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. * Merges an inheritance tree defined by an array of types, considering overrides.
* @template T - An array of types representing the inheritance tree. * @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] T extends [infer Super, infer Self, ...infer Rest]
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>> ? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
? MergeInheritanceTree<[ ? Extend<[
Omit<Super, CommonKeys<Self, Super>> & Self, Omit<Super, CommonKeys<Self, Super>> & Self,
...Rest, ...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. * Merges an inheritance tree defined by an array of types without allowing overrides.
* @template T - An array of types representing the inheritance tree. * @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] T extends [infer Super, infer Self, ...infer Rest]
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>> ? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
? MergeInheritanceTreeWithoutOverriding<[ ? ExtendWithoutOverriding<[
Super & Self, Super & Self,
...Rest, ...Rest,
]> ]>

View File

@@ -1,4 +1,4 @@
export * from "./class" export * from "./class"
export * from "./effect" export * from "./effect"
export * from "./inheritance" export * from "./extend"
export * from "./misc" export * from "./misc"