Skip to content

Commit

Permalink
fix(forms): type NG_VALUE_ACCESSOR injection token as array
Browse files Browse the repository at this point in the history
NG_VALUE_ACCESSOR is a multi injection token, users can and
should expect more than one ControlValueAccessor to be
available (and this is how it is used in @angular/forms).

This is now reflected in the definition of the injection token
by typing it as an array of ControlValueAccessor. The motivating
reason is that using the programmatic Injector api will now
type Injector#get correspondingly.

fixes #29351
  • Loading branch information
Airblader committed May 8, 2020
1 parent b6bc0ae commit 349e3a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion goldens/public-api/forms/forms.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export declare const NG_ASYNC_VALIDATORS: InjectionToken<(Function | Validator)[

export declare const NG_VALIDATORS: InjectionToken<(Function | Validator)[]>;

export declare const NG_VALUE_ACCESSOR: InjectionToken<ControlValueAccessor>;
export declare const NG_VALUE_ACCESSOR: InjectionToken<ControlValueAccessor[]>;

export declare abstract class NgControl extends AbstractControlDirective {
get asyncValidator(): AsyncValidatorFn | null;
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/src/directives/control_value_accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ export interface ControlValueAccessor {
*
* @publicApi
*/
export const NG_VALUE_ACCESSOR = new InjectionToken<ControlValueAccessor>('NgValueAccessor');
export const NG_VALUE_ACCESSOR = new InjectionToken<ControlValueAccessor[]>('NgValueAccessor');

0 comments on commit 349e3a2

Please sign in to comment.