Skip to content

Commit

Permalink
Introduce two new type aliases - LinkFnControllerType and RequireType.
Browse files Browse the repository at this point in the history
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 27, 2018
1 parent 80d50f0 commit 67132da
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 67132da

Please sign in to comment.