GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Signal Forms: [formField] should require nullable types on numeric and date inputs · Issue #72230 · angular/angular

Signal Forms: [formField] should require nullable types on numeric and date inputs #72230

New issue
Copy link
New issue
Copy link
In review
#72231
In review
Signal Forms: [formField] should require nullable types on numeric and date inputs#72230
#72231
Copy link
Labels
area: formsforms: signals
Milestone
needsTriage

Description

@JeanMeche
JeanMeche
opened on Nov 26, 2026
Issue body actions

Description

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:

@Component({
  imports: [FormField],
  template: `
    <input type="date" [formField]="f" />
    <input type="number" [formField]="f2" />
  `,
})
export class App {
  f = form(signal(new Date()));
  f2 = form(signal(3));
}

However, at runtime (getNativeControlValue in packages/forms/signals/src/directive/native.ts), clearing the input sets the signal value to null:

  • <input type="number"> / <input type="datetime-local">: returns null when element.value === "".
  • <input type="date"> / <input type="month"> / <input type="time"> / <input type="week">: returns element.valueAsDate (null when cleared).

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

  1. JeanMeche
    added
    area: forms
    forms: signals
    on Nov 26, 2026
  2. github-project-automation
    added this to Signal Formson Nov 26, 2026
  3. ngbot
    added this to the needsTriage milestone on Nov 26, 2026
  4. github-project-automation
    moved this to In Progress in Signal Formson Nov 26, 2026
  5. JeanMeche
    added a commit that references this issue on Nov 26, 2026

    fix(forms): enforce nullable types for signal form number and date in…

    This issue will close once commit 7bacdee is merged into the 'main' branch.
    7bacdee
  6. github-project-automation
    moved this from In Progress to In Review in Signal Formson Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: formsforms: signals

    Type

    No type

    Projects

    • Signal Forms
      Status
      In Review
      Show more project fields

    Milestone

    • needsTriageNo due date

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.