Fix attempt
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2024-05-11 02:15:48 +02:00
parent f028fb5a32
commit ac64dad81f
2 changed files with 24 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
import { Schema as S } from "@effect/schema" import { Schema as S } from "@effect/schema"
import * as Types from "effect/Types" import * as Types from "effect/Types"
import { Simplify } from "type-fest"
import { Trait, TraitTuple } from "../Trait" import { Trait, TraitTuple } from "../Trait"
import { TraitExpression } from "../TraitExpression" import { TraitExpression } from "../TraitExpression"
import { TraitExpressionBuilder } from "../TraitExpressionBuilder" import { TraitExpressionBuilder } from "../TraitExpressionBuilder"
@@ -40,7 +41,7 @@ export class EffectSchemaInitialTraitExpressionBuilder {
} }
extends< extends<
Super extends S.Class<Self, Fields, I, R, C, Inherited, Proto>, Super extends StaticMembers<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
Self, Self,
Fields extends S.Struct.Fields, Fields extends S.Struct.Fields,
I, R, C, I, R, C,
@@ -49,14 +50,28 @@ export class EffectSchemaInitialTraitExpressionBuilder {
NewFields extends S.Struct.Fields, NewFields extends S.Struct.Fields,
>( >(
superclass: Super | S.Class<Self, Fields, I, R, C, Inherited, Proto>, superclass: Super | StaticMembers<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
identifier: string, identifier: string,
fields: NewFields, fields: NewFields,
annotations?: S.Annotations.Schema<unknown>, annotations?: S.Annotations.Schema<unknown>,
) { ) {
return new EffectSchemaTraitExpressionBuilder( return new EffectSchemaTraitExpressionBuilder(
superclass.extend<unknown>(identifier)(fields, annotations), superclass.extend<unknown>(identifier)(fields, annotations) as S.Class<
{} as Omit<StaticMembers<Super>, keyof S.Class<Self, Fields, I, R, C, Inherited, Proto>>, unknown,
Fields & NewFields,
I & S.Struct.Encoded<NewFields>,
R | S.Struct.Context<NewFields>,
C & S.Struct.Constructor<NewFields>,
Self,
Proto
>,
{} as Simplify<
Omit<Super,
"prototype" | keyof S.Class<Self, Fields, I, R, C, Inherited, Proto>
>
>,
[], [],
) )
} }

View File

@@ -24,7 +24,7 @@ type Extr<T> =
: never : never
type InspectSchemaClass<T> = T extends S.Class<infer Self, infer Fields, infer I, infer R, infer C, infer Inherited, infer Proto> type InspectSchemaClass<T> = T extends S.Class<infer Self, infer Fields, infer I, infer R, infer C, infer Inherited, infer Proto>
? C ? Inherited
: never : never
@@ -38,14 +38,11 @@ const userExp = effectSchemaExpression
.build() .build()
@userExp.staticImplements @userExp.staticImplements
class User extends userExp.extends<User>() implements Implements<typeof userExp> { export class User extends userExp.extends<User>() implements Implements<typeof userExp> {
aMethodThatShouldBeInherited() {} aMethodThatShouldBeInherited() {}
static aStaticMethodThatShouldBeInherited() {} static aStaticMethodThatShouldBeInherited() {}
} }
type T1 = InspectSchemaClass<typeof userExp.superclass>
type T2 = InstanceType<typeof userExp.superclass>
const user = new User({ id: 0n, role: "User" }) const user = new User({ id: 0n, role: "User" })
// user.id = 0n // user.id = 0n
@@ -57,8 +54,10 @@ const adminExp = effectSchemaExpression
// .immutable() // .immutable()
.build() .build()
type T = InspectSchemaClass<typeof adminExp.superclass>
@adminExp.staticImplements @adminExp.staticImplements
class Admin extends adminExp.extends<Admin>() implements Implements<typeof adminExp> { export class Admin extends adminExp.extends<Admin>() implements Implements<typeof adminExp> {
} }
const admin = new Admin({ id: 1n, role: "Admin" }) const admin = new Admin({ id: 1n, role: "Admin" })