diff --git a/src/effect/EffectSchemaTraitExpression.ts b/src/effect/EffectSchemaTraitExpression.ts index a791036..f42b0d9 100644 --- a/src/effect/EffectSchemaTraitExpression.ts +++ b/src/effect/EffectSchemaTraitExpression.ts @@ -1,8 +1,14 @@ import { Schema as S } from "@effect/schema" -import { Simplify } from "type-fest" +import { AbstractClass, AbstractConstructor, Simplify } from "type-fest" import { Trait, TraitTuple } from "../Trait" import { StaticImplements, TraitExpressionLike } from "../TraitExpression" -import { Extend } from "../util" +import { Extend, StaticMembers } from "../util" +import { Types } from "effect" + + +type RequiredKeys = { + [K in keyof T]-?: {} extends Pick ? never : K + }[keyof T] export class EffectSchemaTraitExpression< @@ -26,17 +32,30 @@ implements TraitExpressionLike< extends(): ( - S.Class< - Self, - Fields, - I, R, C, - Simplify< - Extend<[ - Inherited, - ...TraitTuple.MapImplInstance - ]> - >, - Proto + AbstractConstructor< + S.Struct.Type & + Omit & + Proto, + + [ + props: RequiredKeys extends never ? void | {} : Types.Simplify, + disableValidation?: boolean | undefined + ] + > & + + StaticMembers< + S.Class< + Self, + Fields, + I, R, C, + Simplify< + Extend<[ + Inherited, + ...TraitTuple.MapImplInstance + ]> + >, + Proto + > > & Simplify<