Skip to content

Signal Forms - Custom controls - multiple errors #65668

@Merk42

Description

@Merk42

Describe the problem that you experienced

The stateful-input has multiple errors.
value.set(($event.target as HTMLInputElement).value) throws an error about a missing closing parentheses at column 26
disabledReasons = input<readonly DisabledReason[]>([]); throws an error: Property 'disabledReasons' in type 'StatefulInput' is not assignable to the same property in base type 'FormValueControl'.
errors = input<readonly ValidationError.WithField[]>([]); throws an error: Property 'errors' in type 'StatefulInput' is not assignable to the same property in base type 'FormValueControl'.

I attempted to fix the issues by doing the following:
using (input)="update($event)" and creating update($event:any) { this.value.set(($event.target as HTMLInputElement).value) }
changing the disabledReasons type to disabledReasons = input<readonly WithOptionalField<DisabledReason>[]>([]);
changing the errors type to errors = input<readonly WithOptionalField<ValidationError>[]>([]);
and importing the WithOptionalField type from @angular/forms/signals

Enter the URL of the topic with the problem

https://angular.dev/guide/forms/signals/custom-controls#adding-state-signals

Describe what you were looking for in the documentation

A working example of a custom component with the developer preview version of Signal Forms

Describe the actions that led you to experience the problem

Copying and using the stateful-input component in the documentation

Describe what you want to experience that would fix the problem

A successful build

Add a screenshot if that helps illustrate the problem

No response

If this problem caused an exception or error, please paste it here


If the problem is browser-specific, please specify the device, OS, browser, and version


Provide any additional information here in as much as detail as you can


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions