bug(MatFormFieldControl, MatInput): enable empty value for element attributes
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 91
Description
### Is this a regression?
- [x] Yes, this behavior used to work in the previous version
### The previous version in which this bug was not present was
21
### Description
Recent TypeScript 6 flashes out discrepancies in attributes declaration for html/material controls.
For MatInput, as for other controls, TypeScript doesn't allow empty (null or undefined) values.
The `required`, `placeholder`, etc. forces strict datatype while others such as `autocomplete` are optional.
Previous Angluar version 21 handled these cases correct, for example, placeholder in MatFormField.
In my view, all MatFormFieldControl attributes should be optional, to reflect HTML tag design by definition.
It's common to forward optional attributes between components that holds `undefined` value; forcing an issue when refering to HTML tag such as `input` with Angular decoration.
### Reproduction
StackBlitz link: https://stackblitz.com/edit/components-issue-starter-ffzyyuuu?file=src%2Fmain.ts
Steps to reproduce:
See errors for empty placehoder and missing maxlength.
### Expected Behavior
Attributes such as `placeholder` should accept null and undefined.
This should be common among all MatFormFieldControl implementations.
### Actual Behavior
Common attributes doesn't allow empty values.
### Environment
Angular CLI : 22.0.0
Angular : 22.0.0
Node.js : 24.16.0
Package Manager : npm 11.16.0
Operating System : win32 x64
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par la reproduction StackBlitz et examinez les déclarations TypeScript de MatInput ainsi que les implémentations de MatFormFieldControl mentionnées dans l’issue. Confirmez le comportement pour un placeholder vide, maxlength, required et les attributs associés, puis ajoutez ou mettez à jour la couverture afin que null et undefined soient acceptés de manière cohérente.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- frontend
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 56/100