mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
AngularJS: improve types for foreach (support for array-likes)
This commit is contained in:
@@ -710,6 +710,24 @@ function test_angular_forEach() {
|
||||
this.push(`${key}: ${value}`);
|
||||
}, log);
|
||||
// expect(log).toEqual(['name: misko', 'gender: male']);
|
||||
// $ExpectType NodeListOf<HTMLImageElement>
|
||||
angular.forEach(document.getElementsByTagName('img'), (value, key, obj) => {
|
||||
value; // $ExpectType HTMLImageElement
|
||||
key; // $ExpectType number
|
||||
obj; // $ExpectType NodeListOf<HTMLImageElement>
|
||||
});
|
||||
// $ExpectType number[]
|
||||
angular.forEach([1, 2, 3], (value, key, obj) => {
|
||||
value; // $ExpectType number
|
||||
key; // $ExpectType number
|
||||
obj; // $ExpectType number[]
|
||||
});
|
||||
// $ExpectType string
|
||||
angular.forEach('123', (value, key, obj) => {
|
||||
value; // $ExpectType string
|
||||
key; // $ExpectType number
|
||||
obj; // $ExpectType string
|
||||
});
|
||||
}
|
||||
|
||||
// angular.element() tests
|
||||
|
||||
Reference in New Issue
Block a user