From 33000bb5ca7674e1495b7328a885bec4624829af Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 15 Nov 2026 13:40:59 +0300 Subject: [PATCH] docs: fix the input setter coercion example in the template type checking guide The "Input setter coercion" section opened with a signal input that uses `transform: booleanAttribute`, then said that `` is a type error under strict templates. With that transform the attribute form compiles, so the example never showed the problem. The rest of the section is about an `@Input()` setter typed `boolean`. Use a plain `boolean` getter and setter in the first example so it matches the text that follows, update the intro sentence to say the value is altered in the setter, and remove a duplicated "Consider the following directive:" line. (cherry picked from commit 567ae3ed66224270957946dba775548d8b4d8b54) --- .../src/content/tools/cli/template-typecheck.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/adev/src/content/tools/cli/template-typecheck.md b/adev/src/content/tools/cli/template-typecheck.md index 760d47033b6..a41c9d3449e 100644 --- a/adev/src/content/tools/cli/template-typecheck.md +++ b/adev/src/content/tools/cli/template-typecheck.md @@ -201,22 +201,29 @@ See [Improving template type checking for custom directives](/guide/directives/s ## Input setter coercion -Occasionally it is desirable for the `input()` property of a directive or component to alter the value bound to it, typically using a `transform` function for the input. +Occasionally it is desirable for an input of a directive or component to alter the value bound to it, typically in the input's setter. As an example, consider this custom button component: -Consider the following directive: - ```angular-ts @Component({ selector: 'submit-button', template: `
- +
`, }) class SubmitButton { - disabled = input.required({transform: booleanAttribute}); + private _disabled = false; + + @Input() + get disabled(): boolean { + return this._disabled; + } + + set disabled(value: boolean) { + this._disabled = value; + } } ```