AngularJS: compatibility with strictFunctionTypes

Fixes #21160
This commit is contained in:
Georgii Dolzhykov
2017-11-01 15:13:22 +03:00
parent 17f38a9945
commit 44e215bda7
4 changed files with 38 additions and 31 deletions
+18 -6
View File
@@ -707,7 +707,7 @@ class SampleDirective implements ng.IDirective {
restrict = 'A';
name = 'doh';
compile(templateElement: ng.IAugmentedJQuery) {
compile(templateElement: JQLite) {
return {
post: this.link
};
@@ -723,7 +723,7 @@ class SampleDirective implements ng.IDirective {
class SampleDirective2 implements ng.IDirective {
restrict = 'EAC';
compile(templateElement: ng.IAugmentedJQuery) {
compile(templateElement: JQLite) {
return {
pre: this.link
};
@@ -741,7 +741,7 @@ angular.module('SameplDirective', []).directive('sampleDirective', SampleDirecti
angular.module('AnotherSampleDirective', []).directive('myDirective', ['$interpolate', '$q', ($interpolate: ng.IInterpolateService, $q: ng.IQService) => {
return {
restrict: 'A',
link: (scope: ng.IScope, el: ng.IAugmentedJQuery, attr: ng.IAttributes) => {
link: (scope: ng.IScope, el: JQLite, attr: ng.IAttributes) => {
$interpolate(attr['test'])(scope);
$interpolate('', true)(scope);
$interpolate('', true, 'html')(scope);
@@ -869,7 +869,7 @@ angular.module('docsTimeDirective', [])
}])
.directive('myCurrentTime', ['$interval', 'dateFilter', ($interval: any, dateFilter: any) => {
return {
link(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) {
link(scope: ng.IScope, element: JQLite, attrs: ng.IAttributes) {
let format: any;
let timeoutId: any;
@@ -916,7 +916,7 @@ angular.module('docsTransclusionExample', [])
transclude: true,
scope: {},
templateUrl: 'my-dialog.html',
link(scope: ng.IScope, element: ng.IAugmentedJQuery) {
link(scope: ng.IScope, element: JQLite) {
scope['name'] = 'Jeff';
}
};
@@ -1017,7 +1017,7 @@ angular.module('docsTabsExample', [])
scope: {
title: '@'
},
link(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, tabsCtrl: any) {
link(scope: ng.IScope, element: JQLite, attrs: ng.IAttributes, tabsCtrl: any) {
tabsCtrl.addPane(scope);
},
templateUrl: 'my-pane.html'
@@ -1098,6 +1098,18 @@ angular.module('copyExample', [])
$scope.reset();
}]);
// Extending IScope for a directive, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/21160
interface IMyScope extends angular.IScope {
myScopeProperty: boolean;
}
angular.module('aaa').directive('directive', () => ({
link(scope: IMyScope) {
console.log(scope.myScopeProperty);
return;
}
}));
namespace locationTests {
const $location: ng.ILocationService = null;