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

This commit is contained in:
Julien Valverdé
2024-06-18 02:36:01 +02:00
parent ed2de8a0f6
commit a2d7afa6cd
7 changed files with 48 additions and 38 deletions

View File

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

View File

@@ -1,11 +1,11 @@
import type { Struct } from "@effect/schema/Schema"
import { Schema as S } from "@effect/schema"
import { makeObservable, observable, type CreateObservableOptions } from "mobx"
import { mapValues } from "remeda"
interface MobXObservableInput {
new(...args: any[]): Struct.Type<Struct.Fields>
readonly fields: { readonly [K in keyof Struct.Fields]: Struct.Fields[K] }
new(...args: any[]): S.Struct.Type<S.Struct.Fields>
readonly fields: { readonly [K in keyof S.Struct.Fields]: S.Struct.Fields[K] }
}
export function MobXObservable<

View File

@@ -1,5 +1,4 @@
import { Schema as S } from "@effect/schema"
import type { Annotations, Class, Struct } from "@effect/schema/Schema"
import type { Mutable } from "effect/Types"
import type { StaticType } from "../../../StaticType"
import type { HasFields } from "./util"
@@ -7,33 +6,33 @@ import type { HasFields } from "./util"
export interface IMutableClass<
Self,
Fields extends Struct.Fields,
Fields extends S.Struct.Fields,
I, R, C,
Inherited,
Proto,
>
extends Omit<
StaticType<Class<Self, Fields, I, R, C, Inherited, Proto>>,
StaticType<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
"extend"
>
{
new(
...args: ConstructorParameters<Class<Self, Fields, I, R, C, Inherited, Proto>>
...args: ConstructorParameters<S.Class<Self, Fields, I, R, C, Inherited, Proto>>
): Omit<
InstanceType<Class<Self, Fields, I, R, C, Inherited, Proto>>,
InstanceType<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
keyof Fields
> &
Mutable<Struct.Type<Fields>>
Mutable<S.Struct.Type<Fields>>
extend<Extended>(identifier: string): <newFields extends Struct.Fields>(
extend<Extended>(identifier: string): <newFields extends S.Struct.Fields>(
fields: newFields | HasFields<newFields>,
annotations?: Annotations.Schema<Extended>,
annotations?: S.Annotations.Schema<Extended>,
) => IMutableClass<
Extended,
Fields & newFields,
I & Struct.Encoded<newFields>,
R | Struct.Context<newFields>,
C & Struct.Constructor<newFields>,
I & S.Struct.Encoded<newFields>,
R | S.Struct.Context<newFields>,
C & S.Struct.Constructor<newFields>,
Self,
Proto
>
@@ -41,15 +40,15 @@ extends Omit<
export const MutableClass = S.Class as <Self>(identifier: string) =>
<Fields extends Struct.Fields>(
<Fields extends S.Struct.Fields>(
fieldsOr: Fields | HasFields<Fields>,
annotations?: Annotations.Schema<Self>,
annotations?: S.Annotations.Schema<Self>,
) => IMutableClass<
Self,
Fields,
Struct.Encoded<Fields>,
Struct.Context<Fields>,
Struct.Constructor<Fields>,
S.Struct.Encoded<Fields>,
S.Struct.Context<Fields>,
S.Struct.Constructor<Fields>,
{},
{}
>

View File

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

View File

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