Skip to content

fix(core): allow static attributes for explicit input transforms#69729

Draft
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:static-attrs
Draft

fix(core): allow static attributes for explicit input transforms#69729
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:static-attrs

Conversation

@JeanMeche

Copy link
Copy Markdown
Member

This is a follow-up to #67997, which allowed explicit read generics with input transforms, such as input<boolean>(false, {transform: booleanAttribute}).

That fixed the declaration, but static template attributes like dismissible="true" and bare dismissible were still checked as strings against the read type. Allow the fallback write type to include static attribute strings so these template forms compile.

Trying to re-land #69427

This is a follow-up to angular#67997, which allowed explicit read generics with input transforms, such as `input<boolean>(false, {transform: booleanAttribute})`.

That fixed the declaration, but static template attributes like `dismissible="true"` and bare `dismissible` were still checked as strings against the read type. Allow the fallback write type to include static attribute strings so these template forms compile.
@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Jul 10, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jul 10, 2026
@JeanMeche

Copy link
Copy Markdown
Member Author

cc @cexbrayat, this is actually breaking.

ex:

  @Directive()
  class CustomControlDir implements FormValueControl<number> {
    readonly disabled = input<boolean>(false, {transform: booleanAttribute});
  }

@cexbrayat

cexbrayat commented Jul 10, 2026

Copy link
Copy Markdown
Member

Hmm, this approach might not work then. Unless we widen the type for FCV toreadonly disabled?: InputSignalWithTransform<boolean, any>;?

Or maybe this should be abandoned and fixed at the TCB level, but that would require someone with better understanding of the TCB than me I'm afraid.

@JeanMeche

JeanMeche commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

This is something I did look into with #66562, TransformT should be contravariant.

@JoostK

JoostK commented Jul 12, 2026

Copy link
Copy Markdown
Member

Isn't #67997 just undesirable in the first place; the return type InputSignalWithTransform<T, T> is really specifying that the transform function requires a T, whereas it originates from InputOptionsWithTransform<T, unknown>, so the transform's actual write type is much wider (unknown in this case).

If the return type is changed to InputSignalWithTransform<T, unknown> then it would be faithful to the transform's actual type and you wouldn't have this problem. This does, however, amplify that this specific overload is only usable for transform functions that take unknown as input type, at which point I'm not sure it's worth having it at all.

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