mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Improve module.filter() by allowing $stateful to be defined.
This commit is contained in:
parent
80d50f06cf
commit
f6a902f8ce
@ -214,11 +214,18 @@ mod.factory({
|
||||
name1(foo: any) {},
|
||||
name2: ['foo', (foo: any) => {}]
|
||||
});
|
||||
mod.filter('name', ($scope: ng.IScope) => {});
|
||||
mod.filter('name', ['$scope', ($scope: ng.IScope) => {}]);
|
||||
mod.filter('name', ($scope: ng.IScope) => () => {});
|
||||
mod.filter('name', ['$scope', ($scope: ng.IScope) => () => {}]);
|
||||
mod.filter({
|
||||
name1(foo: any) {},
|
||||
name2: ['foo', (foo: any) => {}]
|
||||
name1(foo: any) { return () => {}; },
|
||||
name2: ['foo', (foo: any) => () => {}],
|
||||
});
|
||||
const customStatefulFilter: ng.FilterFunction<(s: string) => number> = (s) => 1;
|
||||
mod.filter('name', () => customStatefulFilter);
|
||||
mod.filter('name', ['$scope', () => customStatefulFilter]);
|
||||
mod.filter({
|
||||
name1: () => customStatefulFilter,
|
||||
name2: ['foo', () => customStatefulFilter],
|
||||
});
|
||||
mod.provider('name', ($scope: ng.IScope) => ({ $get: () => { } }));
|
||||
mod.provider('name', TestProvider);
|
||||
|
||||
13
types/angular/index.d.ts
vendored
13
types/angular/index.d.ts
vendored
@ -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<Function>): IModule;
|
||||
filter(object: {[name: string]: Injectable<Function>}): IModule;
|
||||
filter(name: string, filterFactoryFunction: Injectable<FilterFactory<Function>>): IModule;
|
||||
filter(object: {[name: string]: Injectable<FilterFactory<Function>>}): IModule;
|
||||
provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule;
|
||||
provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule;
|
||||
provider(name: string, inlineAnnotatedConstructor: any[]): IModule;
|
||||
@ -2237,4 +2237,13 @@ declare namespace angular {
|
||||
interface IHttpParamSerializer {
|
||||
(obj: Object): string;
|
||||
}
|
||||
|
||||
type FilterFunction<Filter 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>;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user