See https://docs.angularjs.org/api/ng/service/$compile
"You can either return a Directive Definition Object (see below) that defines the directive properties, or just the postLink function (all other properties will have the default values)."
Interfaces for scope property in Directive and bindings property in Component to avoid using simple Object (not descriptive enough) and the explicit type {[binding: string]: string} which is too verbose.
The $onChanges method of the IComponentController interface has the type in-lined, making it impossible to refer to it. A new interface was added to encapsulate this type, so that it can be easily used and extended.
In angular you can either write `directive('myDirective', ['$http', function($http) {...}])`, which is minification safe, but it's also possible to write `directive('myDirective', function($http) {...})` which might not be minification safe, but valid angular nonetheless.
These tests try to exercise the different ways that the $transclude can be
called including:
+ With and without specifying the scope explicitly
+ With and without a clone attach function
+ With and without specifying the future parent
+ Using the default and named transclude slots
A couple of additional optional parameters were added to the `$transclude`
function when support for multi-slot transclusion was added in Angular 1.5 [1].
This commit updates the `ITranscludeFunction` type definition to reflect those
changes.
[1] https://docs.angularjs.org/api/ng/service/$compile#-controller-
Rename name property from ng.IDirective as there is no mention of this property in the official API documentation (https://docs.angularjs.org/api/ng/service/$compile) and it was causing issues with directives made as classes like so:
class MyDirective implements ng.IDirective {
public template = "<div>{{ test }}</div>";
public scope = {
test: "="
};
public static name = "myDirective";
public static $inject: string[] = ["$http"];
constructor(private $http: ng.IHttpService) {
}
public link(scope: IDirectiveScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) {
}
}
angular.module("app")
.directive(MyDirective.name, DirectiveFactory.getFactoryFor(UserProjectRoles));
See http://stackoverflow.com/questions/38853868/typeerror-when-class-has-static-member-name for more details.
Changing it to another non-reserved name fixes the issue.
Typescript 2.0 starts checking the compatibility of the index
signature with the base JQuery interface; Hence we are forced to
return Document & HTMLElement to be compatible with the base.
JQ(lite)-unwrapping $document[0] should be of type Document instead of
the default HTMLElement. Otherwise important methods like
getElementById are missing.
Angular 1.5+ component Controllers have four new lifecycle hooks:
$onInit()
$onDestroy()
$onChanges(...)
$postInit()
There is currently no reference to any of then in the definitions files.
I added an additional interface to the component's controller type that defines the new hooks with the official documentation from docs.angularjs.org