From f5ec4969d0cd6506b08d4efa9921093437843285 Mon Sep 17 00:00:00 2001 From: Quentin Bouygues Date: Mon, 17 Dec 2018 10:13:25 +0100 Subject: [PATCH] test only directive function using custom types for link function --- types/angular/angular-tests.ts | 62 +++++++--------------------------- 1 file changed, 12 insertions(+), 50 deletions(-) diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index b3a8f2fd67..b83a41a6df 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -1513,55 +1513,17 @@ interface MyController extends ng.INgModelController { foo: string; } -const directiveCompileFnWithGeneric: ng.IDirectiveCompileFn = ( - templateElement: MyElement, - templateAttributes: MyAttributes, - transclude: ng.ITranscludeFunction, - ): ng.IDirectiveLinkFn => { - return ( - scope: MyScope, - instanceElement: MyElement, - instanceAttributes: MyAttributes, - controller: MyController, - ) => { - return null; - }; -}; - -const directiveFactoryWithGeneric: ng.IDirectiveFactory = ( - templateElement: MyElement, - templateAttributes: MyAttributes, - transclude: ng.ITranscludeFunction, -): ng.IDirective => { - return { - link: ($scope: MyScope, templateElement: MyElement, templateAttributes: MyAttributes, controller: MyController) => {return; } - }; -}; - -const directiveFactoryWithGeneric2: ng.IDirectiveFactory = ( - templateElement: MyElement, - templateAttributes: MyAttributes, - transclude: ng.ITranscludeFunction, -): ng.IDirectiveLinkFn => { - return ($scope: MyScope, templateElement: MyElement, templateAttributes: MyAttributes, controller: MyController) => {return; }; -}; - -angular.module('WithGenerics', []).directive('usingDirectiveFactoryWithGeneric', directiveFactoryWithGeneric).directive('usingDirectiveFactoryWithGeneric2', directiveFactoryWithGeneric2); - -class DirectiveWithGenerics implements ng.IDirective { - restrict = 'EAC'; - - compile(templateElement: MyElement) { +angular.module('WithGenerics', []) + .directive('directiveUsingGenerics', () => { return { - pre: this.link + restrict: 'E', + link(scope: MyScope, element: MyElement, templateAttributes: MyAttributes, controller: MyController) { + scope['name'] = 'Jeff'; + } }; - } - - static instance(): ng.IDirective { - return new DirectiveWithGenerics(); - } - - link($scope: MyScope, templateElement: MyElement, templateAttributes: MyAttributes, controller: MyController) {} -} - -angular.module('WithGenerics', []).directive('directiveWithGenerics', DirectiveWithGenerics.instance); + }) + .directive('linkFunctionUsingGenerics', () => { + return (scope: MyScope, element: MyElement, templateAttributes: MyAttributes, controller: MyController) => { + scope['name'] = 'Jeff'; + }; + });