diff --git a/angular/angular-tests.ts b/angular/angular-tests.ts index 4e1f33ce47..b4e394aa37 100644 --- a/angular/angular-tests.ts +++ b/angular/angular-tests.ts @@ -587,7 +587,8 @@ namespace TestPromise { function test_angular_forEach() { const values: { [key: string]: string } = { name: 'misko', gender: 'male' }; const log: string[] = []; - angular.forEach(values, (value, key) => { + angular.forEach(values, (value, key, obj) => { + obj[key] = value; this.push(key + ': ' + value); }, log); // expect(log).toEqual(['name: misko', 'gender: male']); diff --git a/angular/index.d.ts b/angular/index.d.ts index bbbbdb021a..05b6ce92ff 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -97,7 +97,7 @@ declare namespace angular { * @param iterator Iterator function. * @param context Object to become context (this) for the iterator function. */ - forEach(obj: T[], iterator: (value: T, key: number) => any, context?: any): any; + forEach(obj: T[], iterator: (value: T, key: number, obj: T[]) => void, context?: any): T[]; /** * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. * @@ -107,7 +107,7 @@ declare namespace angular { * @param iterator Iterator function. * @param context Object to become context (this) for the iterator function. */ - forEach(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any; + forEach(obj: { [index: string]: T; }, iterator: (value: T, key: string, obj: { [index: string]: T; }) => void, context?: any): { [index: string]: T; }; /** * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. * @@ -117,7 +117,7 @@ declare namespace angular { * @param iterator Iterator function. * @param context Object to become context (this) for the iterator function. */ - forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any; + forEach(obj: any, iterator: (value: any, key: any, obj: any) => void, context?: any): any; fromJson(json: string): any; identity(arg?: T): T;