angular / angular/components

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

Aperta
#33,353 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
area: many gemini-triaged P4
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la riproduzione su StackBlitz e ispeziona le dichiarazioni TypeScript per MatInput e le implementazioni di MatFormFieldControl menzionate nell’issue. Conferma il comportamento per placeholder vuoto, maxlength, required e gli attributi correlati, quindi aggiungi o aggiorna la coverage in modo che null e undefined siano accettati in modo coerente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
56/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.