Refactor Form
Some checks failed
Lint / lint (push) Failing after 13s

This commit is contained in:
Julien Valverdé
2026-03-28 21:42:11 +01:00
parent c6655ba168
commit 4fdaca2973

View File

@@ -23,13 +23,9 @@ extends Pipeable.Pipeable {
readonly canSubmit: Subscribable.Subscribable<boolean, never, never>
}
export const FormImplTypeId: unique symbol = Symbol.for("@effect-fc/Form/FormImpl")
export type FormImplTypeId = typeof FormImplTypeId
export class FormImpl<in out P extends readonly PropertyKey[], in out A, in out I = A, in out ER = never, in out EW = never>
extends Pipeable.Class() implements Form<P, A, I, ER, EW> {
readonly [FormTypeId]: FormTypeId = FormTypeId
readonly [FormImplTypeId]: FormImplTypeId = FormImplTypeId
constructor(
readonly path: P,
@@ -64,9 +60,12 @@ extends Form<readonly [], A, I, never, never> {
}
export class RootFormImpl<in out A, in out I = A, in out R = never, in out MA = void, in out ME = never, in out MR = never, in out MP = never>
extends FormImpl<readonly [], A, I> implements RootForm<A, I, R, MA, ME, MR, MP> {
extends Pipeable.Class() implements RootForm<A, I, R, MA, ME, MR, MP> {
readonly [FormTypeId]: FormTypeId = FormTypeId
readonly [RootFormTypeId]: RootFormTypeId = RootFormTypeId
readonly path = [] as const
constructor(
readonly schema: Schema.Schema<A, I, R>,
readonly context: Context.Context<Scope.Scope | R>,
@@ -85,14 +84,7 @@ extends FormImpl<readonly [], A, I> implements RootForm<A, I, R, MA, ME, MR, MP>
readonly runSemaphore: Effect.Semaphore,
) {
super(
[],
value,
encodedValue,
error,
isValidating,
canSubmit,
)
super()
}
get run(): Effect.Effect<void> {
@@ -166,7 +158,6 @@ extends FormImpl<readonly [], A, I> implements RootForm<A, I, R, MA, ME, MR, MP>
export const isForm = (u: unknown): u is Form<readonly PropertyKey[], unknown, unknown> => Predicate.hasProperty(u, FormTypeId)
export const isFormImpl = (u: unknown): u is FormImpl<readonly PropertyKey[], unknown, unknown> => Predicate.hasProperty(u, FormImplTypeId)
export const isRootForm = (u: unknown): u is RootForm<readonly PropertyKey[], unknown, unknown, unknown, unknown, unknown, unknown> => Predicate.hasProperty(u, RootFormTypeId)