Skip to content

Commit

Permalink
fix: correct FormGroup array types
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Feb 6, 2024
1 parent 3730d4e commit 90d7705
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/example/src/app/simple-form/simple-form.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, inject, Signal } from '@angular/core';
import {
FormField,
FormGroup,
SetValidationState,
SignalFormBuilder,
SignalInputDebounceDirective,
Expand Down Expand Up @@ -159,7 +160,7 @@ export default class SimpleFormComponent {
),
};
}),
todos: this.sfb.createFormGroup<Todo[]>(
todos: this.sfb.createFormGroup<FormGroup<Todo>[]>(
() => {
return [];
},
Expand Down
4 changes: 3 additions & 1 deletion packages/platform/src/lib/form-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import {
export type FormGroup<Fields extends FormGroupCreatorOrSignal = {}> = {
__type: 'FormGroup';
value: Signal<UnwrappedFormGroup<Fields>>;
controls: Fields extends WritableSignal<FormGroup<infer FG>[]> ? WritableSignal<FormGroup<FG>[]> : FormGroupFields<Fields>;
controls: Fields extends WritableSignal<FormGroup<infer G>[]>
? FormGroupFields<Fields> & WritableSignal<FormGroup<G>[]>
: FormGroupFields<Fields>;
valid: Signal<boolean>;
state: Signal<ValidationState>;
dirtyState: Signal<DirtyState>;
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/src/lib/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type FormGroupFields<Fields extends FormGroupCreatorOrSignal> = {
? FormField<Fields[K]>
: Fields[K] extends FormGroup<infer G>
? G extends unknown[]
? FormGroup<WritableSignal<FormGroup<G[0]>[]>>
? FormGroup<WritableSignal<G[0][]>>
: Fields[K]
: Fields[K];
};
Expand Down

0 comments on commit 90d7705

Please sign in to comment.