You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Signal Forms: [formField] should require nullable types on numeric and date inputs #72230
Currently, TcbNativeFieldOp type-checks [formField] on <input type="number">, <input type="datetime-local">, <input type="date">, <input type="month">, <input type="time">, and <input type="week"> with a covariant read-only check (string | number | null / string | number | Date | null).
Because the check is covariant, non-nullable fields such as form(signal(3)) (Field<number>) on <input type="number"> or form(signal(new Date())) (Field<Date>) on <input type="date"> compile without error:
This violates type soundness by writing null into a WritableSignal<number> or WritableSignal<Date>. It is also inconsistent with <input type="text">, which already uses an invariant structural union check ({ (): string; set: (v: string) => void; } | { (): number | null; set: (v: number | null) => void; }) to reject Field<number> and Field<string | null>.
Proposed solution
Use the same invariant structural union check in TcbNativeFieldOp for:
number, datetime-local: string | number | null
range: string | number | number | null (cannot be cleared to null via browser UI)
date, month, time, week: string | number | Date | null
(Note: number on date/month/time/week returns element.valueAsNumber which is NaN when cleared, not null.)
Activity
fix(forms): enforce nullable types for signal form number and date in…