-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Open
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercompiler: template type-checking
Milestone
Description
Which @angular/* package(s) are relevant/related to the feature request?
forms
Description
Option values for selectable input (select, radio or checkbox) should be type checked when using typed form control.
Proposed solution
value attribute should have the same type as its form control value.
If type does not match, we would have a Typescript error.
Example
Let's say I have a form control with the following type:
country: FormControl<string>
and the following template:
<select [formControl]="country">
<!-- Valid type -->
<option value="France">
<!-- Incorrect types -->
<option [value]="0">
<option [value]="true">
</select>
I want option 0and true to fail to compile, because they do not match the type string.
Same principle would apply to <input type="radio" /> and <input type="checkbox" />.
Alternatives considered
If not doable, could be specific to Angular Material components.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercompiler: template type-checking