Skip to content

Commit

Permalink
(angular.js) Introduce type aliases LinkFnControllerType and RequireT…
Browse files Browse the repository at this point in the history
…ype.

This allows users to write callbacks using those aliases instead of the
full type.

Having convinient aliases is required for having AngularJS in TS work
better with strictFunctionTypes flag on.
see: angular/angular.js#16617

Also having them next to each other shows the symmetry between the
require and controller param better.
  • Loading branch information
rkirov committed Jun 28, 2018
1 parent 80d50f0 commit dcfb038
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions types/angular/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2075,11 +2075,15 @@ declare namespace angular {
scope: TScope,
instanceElement: JQLite,
instanceAttributes: IAttributes,
controller?: IController | IController[] | {[key: string]: IController},
controller?: LinkFnControllerType,
transclude?: ITranscludeFunction
): void;
}

type RequireType = string | string[] | {[key: string]: string};

type LinkFnControllerType = IController | IController[] | {[key: string]: IController};

interface IDirectivePrePost<TScope extends IScope = IScope> {
pre?: IDirectiveLinkFn<TScope>;
post?: IDirectiveLinkFn<TScope>;
Expand Down Expand Up @@ -2116,7 +2120,7 @@ declare namespace angular {
* @deprecated
*/
replace?: boolean;
require?: string | string[] | {[controller: string]: string};
require?: RequireType;
restrict?: string;
scope?: boolean | {[boundProperty: string]: string};
template?: string | ((tElement: JQLite, tAttrs: IAttributes) => string);
Expand Down

0 comments on commit dcfb038

Please sign in to comment.