feat(docs-infra): use Record type instead of key-value (#40463)

use Record type instead of key-value

Closes #39804

PR Close #40463
This commit is contained in:
abarghoud 2021-01-17 19:10:26 +01:00 committed by Andrew Kushnir
parent b636406043
commit 2c95f57266
2 changed files with 6 additions and 6 deletions

View File

@ -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;
}

View File

@ -150,7 +150,7 @@ The following table summarizes class binding syntax.
<td><code>"my-class-1 my-class-2 my-class-3"</code></td>
</tr>
<tr>
<td><code>{[key: string]: boolean | undefined | null}</code></td>
<td><code>Record&lt;string, boolean | undefined | null&gt;</code></td>
<td><code>{foo: true, bar: false}</code></td>
</tr>
<tr>
@ -248,7 +248,7 @@ The following table summarizes style binding syntax.
<td><code>"width: 100px; height: 100px"</code></td>
</tr>
<tr>
<td><code>{[key: string]: string | undefined | null}</code></td>
<td><code>Record&lt;string, string | undefined | null&gt;</code></td>
<td><code>{width: '100px', height: '100px'}</code></td>
</tr>
</table>
@ -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.
</div>
</div>