Test IDirective changes,

cascade generics from IModule's directive function
This commit is contained in:
Quentin Bouygues
2018-12-14 17:21:44 +01:00
parent 7983723f0f
commit d158d782e9
2 changed files with 42 additions and 11 deletions
+37 -7
View File
@@ -1502,16 +1502,46 @@ interface MyScope extends ng.IScope {
foo: string;
}
const directiveCompileFnWithGeneric: ng.IDirectiveCompileFn<MyScope> = (
templateElement: JQLite,
templateAttributes: ng.IAttributes,
transclude: ng.ITranscludeFunction
): ng.IDirectiveLinkFn<MyScope> => {
interface MyElement extends JQLite {
foo: string;
}
interface MyAttributes extends ng.IAttributes {
foo: string;
}
interface MyController extends ng.INgModelController {
foo: string;
}
const directiveCompileFnWithGeneric: ng.IDirectiveCompileFn<MyScope, MyElement, MyAttributes, MyController> = (
templateElement: MyElement,
templateAttributes: MyAttributes,
transclude: ng.ITranscludeFunction,
): ng.IDirectiveLinkFn<MyScope, MyElement, MyAttributes, MyController> => {
return (
scope: MyScope,
instanceElement: JQLite,
instanceAttributes: ng.IAttributes
instanceElement: MyElement,
instanceAttributes: MyAttributes,
controller: MyController,
) => {
return null;
};
};
const directiveFactoryWithGeneric: ng.IDirectiveFactory<MyScope, MyElement, MyAttributes, MyController> = (
templateElement: MyElement,
templateAttributes: MyAttributes,
transclude: ng.ITranscludeFunction,
): ng.IDirective<MyScope, MyElement, MyAttributes, MyController> => {
return {
link: ($scope: MyScope, templateElement: MyElement, templateAttributes: MyAttributes, controller: MyController) => {return; }
};
};
const directiveFactoryWithGeneric2: ng.IDirectiveFactory<MyScope, MyElement, MyAttributes, MyController> = (
templateElement: MyElement,
templateAttributes: MyAttributes,
transclude: ng.ITranscludeFunction,
): ng.IDirectiveLinkFn<MyScope, MyElement, MyAttributes, MyController> => {
return ($scope: MyScope, templateElement: MyElement, templateAttributes: MyAttributes, controller: MyController) => {return; };
};
+5 -4
View File
@@ -240,8 +240,9 @@ 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<TScope extends IScope = IScope>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope>>): IModule;
directive<TScope extends IScope = IScope>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope>>}): IModule;
directive<TScope extends IScope = IScope, TElement extends JQLite = JQLite, TAttributes extends IAttributes = IAttributes, TController extends IDirectiveController = IController>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope, TElement, TAttributes, TController>>): IModule;
directive<TScope extends IScope = IScope, TElement extends JQLite = JQLite, TAttributes extends IAttributes = IAttributes, TController extends IDirectiveController = IController>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope, TElement, TAttributes, TController>>}): 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.
*
@@ -1346,8 +1347,8 @@ declare namespace angular {
}
interface ICompileProvider extends IServiceProvider {
directive<TScope extends IScope = IScope>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope>>): ICompileProvider;
directive<TScope extends IScope = IScope>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope>>}): ICompileProvider;
directive<TScope extends IScope = IScope, TElement extends JQLite = JQLite, TAttributes extends IAttributes = IAttributes, TController extends IDirectiveController = IController>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope, TElement, TAttributes, TController>>): ICompileProvider;
directive<TScope extends IScope = IScope, TElement extends JQLite = JQLite, TAttributes extends IAttributes = IAttributes, TController extends IDirectiveController = IController>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope, TElement, TAttributes, TController>>}): ICompileProvider;
component(name: string, options: IComponentOptions): ICompileProvider;
component(object: {[componentName: string]: IComponentOptions}): ICompileProvider;