Skip to content

fix(core): allow explicit read generic with signal input transforms#67997

Open
cexbrayat wants to merge 1 commit intoangular:mainfrom
cexbrayat:fix/input-transform-explicit-generic
Open

fix(core): allow explicit read generic with signal input transforms#67997
cexbrayat wants to merge 1 commit intoangular:mainfrom
cexbrayat:fix/input-transform-explicit-generic

Conversation

@cexbrayat
Copy link
Copy Markdown
Member

@cexbrayat cexbrayat commented Apr 2, 2026

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Using explicit single generic arguments with transforms, e.g. input<boolean>(false, {transform: booleanAttribute}), failed overload resolution.

Before this fix, type-checking produced:

 [ERROR] TS2769: No overload matches this call.
  Overload 1 of 5, '(initialValue: boolean, opts?: InputOptionsWithoutTransform<boolean> | undefined): InputSignal<boolean>', gave the following error.
    Type '(value: unknown) => boolean' is not assignable to type 'undefined'.
  Overload 2 of 5, '(initialValue: undefined, opts: InputOptionsWithoutTransform<boolean>): InputSignal<boolean | undefined>', gave the following error.
    Argument of type 'true' is not assignable to parameter of type 'undefined'. [plugin angular-compiler]

What is the new behavior?

Add specialized overloads for input(...) with transform write type equal to read type, and add signature tests for booleanAttribute/numberAttribute with both defined and undefined initial values.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Using explicit single generic arguments with transforms, e.g.
`input<boolean>(false, {transform: booleanAttribute})`, failed overload
resolution.

Before this fix, type-checking produced:
````
✘ [ERROR] TS2769: No overload matches this call.
  Overload 1 of 5, '(initialValue: boolean, opts?: InputOptionsWithoutTransform<boolean> | undefined): InputSignal<boolean>', gave the following error.
    Type '(value: unknown) => boolean' is not assignable to type 'undefined'.
  Overload 2 of 5, '(initialValue: undefined, opts: InputOptionsWithoutTransform<boolean>): InputSignal<boolean | undefined>', gave the following error.
    Argument of type 'true' is not assignable to parameter of type 'undefined'. [plugin angular-compiler]
```

Add specialized overloads for `input(...)` with transform write type equal to
read type, and add signature tests for `booleanAttribute`/`numberAttribute`
with both defined and undefined initial values.
@pullapprove pullapprove bot requested a review from kirjs April 2, 2026 10:20
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Apr 2, 2026
@ngbot ngbot bot added this to the Backlog milestone Apr 2, 2026
@JeanMeche
Copy link
Copy Markdown
Member

That would be a fix for #53969, right ?

@cexbrayat
Copy link
Copy Markdown
Member Author

@JeanMeche Indeed, it looks like it is! 👍

According to the discussion between @JoostK and @devversion , maybe my fix is too naive?

But maybe it is a usable workaround until TS natively support it (even if the linked PR upstream has been closed, so it might not be soon).

@JoostK
Copy link
Copy Markdown
Member

JoostK commented Apr 3, 2026

This is interesting, I hadn't considered this. Would this behave the same as specifying TransformT = T?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Issues related to the framework runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants