Simplify filterfunction using interface instead of silly type

This commit is contained in:
Oscar Busk
2018-06-28 22:21:06 +02:00
parent f6a902f8ce
commit 4ef49ba480
2 changed files with 7 additions and 7 deletions

View File

@@ -220,7 +220,7 @@ mod.filter({
name1(foo: any) { return () => {}; },
name2: ['foo', (foo: any) => () => {}],
});
const customStatefulFilter: ng.FilterFunction<(s: string) => number> = (s) => 1;
const customStatefulFilter: ng.IFilterFunction = (s) => 1;
mod.filter('name', () => customStatefulFilter);
mod.filter('name', ['$scope', () => customStatefulFilter]);
mod.filter({

View File

@@ -250,8 +250,8 @@ declare namespace angular {
*/
factory(name: string, $getFn: Injectable<Function>): IModule;
factory(object: {[name: string]: Injectable<Function>}): IModule;
filter(name: string, filterFactoryFunction: Injectable<FilterFactory<Function>>): IModule;
filter(object: {[name: string]: Injectable<FilterFactory<Function>>}): IModule;
filter(name: string, filterFactoryFunction: Injectable<FilterFactory>): IModule;
filter(object: {[name: string]: Injectable<FilterFactory>}): IModule;
provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule;
provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule;
provider(name: string, inlineAnnotatedConstructor: any[]): IModule;
@@ -2238,12 +2238,12 @@ declare namespace angular {
(obj: Object): string;
}
type FilterFunction<Filter extends Function> = {
interface IFilterFunction extends Function {
/**
* By default, filters are only run once the input value changes. By marking the filter as `$stateful`, the filter will be run on every `$digest` to update the output. **This is strongly discouraged.**
* See https://docs.angularjs.org/guide/filter#stateful-filters
*/
$stateful?: boolean
} & Filter;
type FilterFactory<Filter extends Function> = (...I: any[]) => FilterFunction<Filter>;
$stateful?: boolean;
}
type FilterFactory = (...I: any[]) => IFilterFunction;
}