Refactoring
All checks were successful
Lint / lint (push) Successful in 11s

This commit is contained in:
Julien Valverdé
2024-06-16 04:12:28 +02:00
parent c5c0b5b952
commit 6fac7c7321
5 changed files with 57 additions and 50 deletions

View File

@@ -3,18 +3,16 @@ import type { Annotations, Struct } from "@effect/schema/Schema"
import type { HasFields } from "./util"
export function Class<Self>(identifier: string) {
return <Fields extends Struct.Fields>(
export const Class = S.Class as <Self>(identifier: string) =>
<Fields extends Struct.Fields>(
fieldsOr: Fields | HasFields<Fields>,
annotations?: Annotations.Schema<Self>,
) =>
S.Class<Self>(identifier)(fieldsOr, annotations) as S.Class<
Self,
Fields,
Struct.Encoded<Fields>,
Struct.Context<Fields>,
Struct.Constructor<Fields>,
{},
{}
>
}
) => S.Class<
Self,
Fields,
Struct.Encoded<Fields>,
Struct.Context<Fields>,
Struct.Constructor<Fields>,
{},
{}
>

View File

@@ -40,18 +40,16 @@ extends Omit<
}
export function MutableClass<Self>(identifier: string) {
return <Fields extends Struct.Fields>(
export const MutableClass = S.Class as <Self>(identifier: string) =>
<Fields extends Struct.Fields>(
fieldsOr: Fields | HasFields<Fields>,
annotations?: Annotations.Schema<Self>,
) =>
S.Class<Self>(identifier)(fieldsOr, annotations) as IMutableClass<
Self,
Fields,
Struct.Encoded<Fields>,
Struct.Context<Fields>,
Struct.Constructor<Fields>,
{},
{}
>
}
) => IMutableClass<
Self,
Fields,
Struct.Encoded<Fields>,
Struct.Context<Fields>,
Struct.Constructor<Fields>,
{},
{}
>

View File

@@ -1,26 +1,38 @@
import { Schema as S } from "@effect/schema"
import type { Annotations, Struct } from "@effect/schema/Schema"
import type { Annotations, PropertySignature, Struct } from "@effect/schema/Schema"
import type { IMutableClass } from "./MutableClass"
import type { HasFields } from "./util"
export function MutableTaggedClass<Self>(identifier?: string) {
return <
export interface IMutableTaggedClass<
Self,
Tag,
Fields extends Struct.Fields,
>
extends IMutableClass<
Self,
Fields,
Struct.Encoded<Fields>,
Struct.Context<Fields>,
Struct.Constructor<Omit<Fields, "_tag">>,
{},
{}
>
{
readonly _tag: Tag
}
export const MutableTaggedClass = S.TaggedClass as <Self>(identifier?: string) =>
<
Tag extends string,
Fields extends Struct.Fields,
>(
tag: Tag,
fieldsOr: Fields | HasFields<Fields>,
annotations?: Annotations.Schema<Self>,
) =>
S.TaggedClass<Self>(identifier)(tag, fieldsOr, annotations) as IMutableClass<
Self,
Fields,
Struct.Encoded<Fields>,
Struct.Context<Fields>,
Struct.Constructor<Omit<Fields, "_tag">>,
{},
{}
> &
{ readonly _tag: Tag }
}
) => IMutableTaggedClass<
Self,
Tag,
{ readonly _tag: PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
>

View File

@@ -3,18 +3,16 @@ import type { Annotations, PropertySignature, Struct } from "@effect/schema/Sche
import type { HasFields } from "./util"
export function TaggedClass<Self>(identifier?: string) {
return <
export const TaggedClass = S.TaggedClass as <Self>(identifier?: string) =>
<
Tag extends string,
Fields extends Struct.Fields,
>(
tag: Tag,
fieldsOr: Fields | HasFields<Fields>,
annotations?: Annotations.Schema<Self>,
) =>
S.TaggedClass<Self>(identifier)(tag, fieldsOr, annotations) as S.TaggedClass<
Self,
Tag,
{ readonly _tag: PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
>
}
) => S.TaggedClass<
Self,
Tag,
{ readonly _tag: PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
>

View File

@@ -3,4 +3,5 @@ export { MobXObservable } from "./MobXObservable"
export { MutableClass } from "./MutableClass"
export type { IMutableClass } from "./MutableClass"
export { MutableTaggedClass } from "./MutableTaggedClass"
export type { IMutableTaggedClass } from "./MutableTaggedClass"
export { TaggedClass } from "./TaggedClass"