diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts
index 9c0671601f..b4b626b9fa 100644
--- a/types/angular/angular-tests.ts
+++ b/types/angular/angular-tests.ts
@@ -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;
diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts
index 45b9bea058..e16baf0a80 100644
--- a/types/angular/index.d.ts
+++ b/types/angular/index.d.ts
@@ -9,9 +9,6 @@
///
-// NOTE: @types/angular technically doesn't require TypeScript 2.3, only TypeScript 2.1.
-// It has a TypeScript 2.3 header so that merging tests with @types/jquery v3 will work.
-
declare var angular: angular.IAngularStatic;
// Support for painless dependency injection
@@ -232,8 +229,8 @@ declare namespace angular {
* @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
* @param directiveFactory An injectable directive factory function.
*/
- directive(name: string, directiveFactory: Injectable): IModule;
- directive(object: {[directiveName: string]: Injectable}): IModule;
+ directive(name: string, directiveFactory: Injectable>): IModule;
+ directive(object: {[directiveName: string]: Injectable>}): IModule;
/**
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
*
@@ -1252,8 +1249,8 @@ declare namespace angular {
}
interface ICompileProvider extends IServiceProvider {
- directive(name: string, directiveFactory: Injectable): ICompileProvider;
- directive(object: {[directiveName: string]: Injectable}): ICompileProvider;
+ directive(name: string, directiveFactory: Injectable>): ICompileProvider;
+ directive(object: {[directiveName: string]: Injectable>}): ICompileProvider;
component(name: string, options: IComponentOptions): ICompileProvider;
@@ -1961,13 +1958,13 @@ declare namespace angular {
// and http://docs.angularjs.org/guide/directive
///////////////////////////////////////////////////////////////////////////
- interface IDirectiveFactory {
- (...args: any[]): IDirective | IDirectiveLinkFn;
+ interface IDirectiveFactory {
+ (...args: any[]): IDirective | IDirectiveLinkFn;
}
- interface IDirectiveLinkFn {
+ interface IDirectiveLinkFn {
(
- scope: IScope,
+ scope: TScope,
instanceElement: JQLite,
instanceAttributes: IAttributes,
controller?: IController | IController[] | {[key: string]: IController},
@@ -1975,12 +1972,12 @@ declare namespace angular {
): void;
}
- interface IDirectivePrePost {
- pre?: IDirectiveLinkFn;
- post?: IDirectiveLinkFn;
+ interface IDirectivePrePost {
+ pre?: IDirectiveLinkFn;
+ post?: IDirectiveLinkFn;
}
- interface IDirectiveCompileFn {
+ interface IDirectiveCompileFn {
(
templateElement: JQLite,
templateAttributes: IAttributes,
@@ -1991,11 +1988,11 @@ declare namespace angular {
* that is passed to the link function instead.
*/
transclude: ITranscludeFunction
- ): void | IDirectiveLinkFn | IDirectivePrePost;
+ ): void | IDirectiveLinkFn | IDirectivePrePost;
}
- interface IDirective {
- compile?: IDirectiveCompileFn;
+ interface IDirective {
+ compile?: IDirectiveCompileFn;
controller?: string | Injectable;
controllerAs?: string;
/**
@@ -2004,7 +2001,7 @@ declare namespace angular {
* relies upon bindings inside a $onInit method on the controller, instead.
*/
bindToController?: boolean | {[boundProperty: string]: string};
- link?: IDirectiveLinkFn | IDirectivePrePost;
+ link?: IDirectiveLinkFn | IDirectivePrePost;
multiElement?: boolean;
priority?: number;
/**
@@ -2077,9 +2074,7 @@ declare namespace angular {
get(name: '$xhrFactory'): IXhrFactory;
has(name: string): boolean;
instantiate(typeConstructor: {new(...args: any[]): T}, locals?: any): T;
- invoke(inlineAnnotatedFunction: any[], context?: any, locals?: any): any;
- invoke(func: (...args: any[]) => T, context?: any, locals?: any): T;
- invoke(func: Function, context?: any, locals?: any): any;
+ invoke(func: Injectable T)>, context?: any, locals?: any): T;
strictDi: boolean;
}
diff --git a/types/angular/tsconfig.json b/types/angular/tsconfig.json
index 92d1e026c3..5ce810f938 100644
--- a/types/angular/tsconfig.json
+++ b/types/angular/tsconfig.json
@@ -16,7 +16,7 @@
"noImplicitAny": false,
"noImplicitThis": false,
"strictNullChecks": false,
- "strictFunctionTypes": false,
+ "strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -25,4 +25,4 @@
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
-}
\ No newline at end of file
+}
diff --git a/types/ngprogress-lite/ngprogress-lite-tests.ts b/types/ngprogress-lite/ngprogress-lite-tests.ts
index c4b903d78b..2cdfa53661 100644
--- a/types/ngprogress-lite/ngprogress-lite-tests.ts
+++ b/types/ngprogress-lite/ngprogress-lite-tests.ts
@@ -4,7 +4,7 @@ app.config(
['ngProgressLiteProvider',
(ngProgressLiteProvider: ng.progressLite.INgProgressLiteProvider) => {
ngProgressLiteProvider.settings.ease = 'ease';
- ngProgressLiteProvider.settings.minimum = 0.08,
+ ngProgressLiteProvider.settings.minimum = 0.08;
ngProgressLiteProvider.settings.speed = 300;
ngProgressLiteProvider.settings.trickleRate = 0.02;
ngProgressLiteProvider.settings.trickleSpeed = 500;