mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
angularjs - better granularity for filter service parameter types
This commit is contained in:
@@ -933,3 +933,19 @@ function NgModelControllerTyping() {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function ngFilterTyping() {
|
||||
var $filter: angular.IFilterService;
|
||||
var items: string[];
|
||||
|
||||
$filter("name")(items, "test");
|
||||
$filter("name")(items, {name: "test"});
|
||||
$filter("name")(items, (val, index, array) => {
|
||||
return array;
|
||||
});
|
||||
$filter("name")(items, (val, index, array) => {
|
||||
return array;
|
||||
}, (actual, expected) => {
|
||||
return actual == expected;
|
||||
});
|
||||
}
|
||||
18
angularjs/angular.d.ts
vendored
18
angularjs/angular.d.ts
vendored
@@ -782,7 +782,23 @@ declare module angular {
|
||||
*
|
||||
* @param name Name of the filter function to retrieve
|
||||
*/
|
||||
(name: string): Function;
|
||||
(name: string): IFilterFunc;
|
||||
}
|
||||
|
||||
interface IFilterFunc {
|
||||
<T>(array: T[], expression: string | IFilterPatternObject | IFilterPredicateFunc<T>, comparator?: IFilterComparatorFunc<T>|boolean): T[];
|
||||
}
|
||||
|
||||
interface IFilterPatternObject {
|
||||
[name: string]: string;
|
||||
}
|
||||
|
||||
interface IFilterPredicateFunc<T> {
|
||||
(value: T, index: number, array: T[]): T[];
|
||||
}
|
||||
|
||||
interface IFilterComparatorFunc<T> {
|
||||
(actual: T, expected: T): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user