angular / angular/components

bug(MatFormFieldControl, MatInput): enable empty value for element attributes

Offen
#33,353 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: many gemini-triaged P4
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der StackBlitz-Reproduktion und prüfe die TypeScript-Deklarationen für MatInput sowie die in diesem Issue genannten Implementierungen von MatFormFieldControl. Bestätige das Verhalten für leeren placeholder, maxlength, required und verwandte Attribute und ergänze oder aktualisiere anschließend die Testabdeckung, sodass null und undefined konsistent akzeptiert werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
56/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.