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 10, 2019
1 parent 9abf114 commit 3f20102
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
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');
2 changes: 1 addition & 1 deletion tools/public_api_guard/forms/forms.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,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 {
readonly asyncValidator: AsyncValidatorFn | null;
Expand Down

0 comments on commit 3f20102

Please sign in to comment.