From 2c95f57266b4024f1181267b1217d663308d6a1c Mon Sep 17 00:00:00 2001 From: abarghoud Date: Sun, 17 Jan 2021 19:10:26 +0100 Subject: [PATCH] feat(docs-infra): use Record type instead of key-value (#40463) use Record type instead of key-value Closes #39804 PR Close #40463 --- .../src/app/shared/forbidden-name.directive.ts | 6 +++--- aio/content/guide/attribute-binding.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aio/content/examples/form-validation/src/app/shared/forbidden-name.directive.ts b/aio/content/examples/form-validation/src/app/shared/forbidden-name.directive.ts index 0c4f8b18c0..60510fe6c6 100644 --- a/aio/content/examples/form-validation/src/app/shared/forbidden-name.directive.ts +++ b/aio/content/examples/form-validation/src/app/shared/forbidden-name.directive.ts @@ -1,6 +1,6 @@ // #docregion -import { Directive, Input, OnChanges, SimpleChanges } from '@angular/core'; -import { AbstractControl, NG_VALIDATORS, Validator, ValidatorFn, Validators } from '@angular/forms'; +import { Directive, Input } from '@angular/core'; +import { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator, ValidatorFn } from '@angular/forms'; // #docregion custom-validator /** A hero's name can't match the given regular expression */ @@ -22,7 +22,7 @@ export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { export class ForbiddenValidatorDirective implements Validator { @Input('appForbiddenName') forbiddenName: string; - validate(control: AbstractControl): {[key: string]: any} | null { + validate(control: AbstractControl): ValidationErrors | null { return this.forbiddenName ? forbiddenNameValidator(new RegExp(this.forbiddenName, 'i'))(control) : null; } diff --git a/aio/content/guide/attribute-binding.md b/aio/content/guide/attribute-binding.md index d051319b5e..81597a9fea 100644 --- a/aio/content/guide/attribute-binding.md +++ b/aio/content/guide/attribute-binding.md @@ -150,7 +150,7 @@ The following table summarizes class binding syntax. "my-class-1 my-class-2 my-class-3" - {[key: string]: boolean | undefined | null} + Record<string, boolean | undefined | null> {foo: true, bar: false} @@ -248,7 +248,7 @@ The following table summarizes style binding syntax. "width: 100px; height: 100px" - {[key: string]: string | undefined | null} + Record<string, string | undefined | null> {width: '100px', height: '100px'} @@ -362,4 +362,4 @@ Another example is the [RouterOutlet](api/router/RouterOutlet) directive, which Remember, use [@Input()](api/core/Input) when you want to keep track of the attribute value and update the associated property. Use [@Attribute()](api/core/Attribute) when you want to inject the value of an HTML attribute to a component or directive constructor. - \ No newline at end of file +