Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

chore(types): make ElementArrayFinder more generic #3977

Merged
merged 1 commit into from
Jan 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class ElementArrayFinder extends WebdriverWebElement {
* array
* of element that satisfy the filter function.
*/
filter(filterFn: Function): ElementArrayFinder {
filter(filterFn: (element: ElementFinder, index?: number) => any): ElementArrayFinder {
let getWebElements = (): wdpromise.Promise<WebElement[]> => {
return this.getWebElements().then((parentWebElements: WebElement[]) => {
let list = parentWebElements.map((parentWebElement: WebElement, index: number) => {
Expand Down Expand Up @@ -483,7 +483,7 @@ export class ElementArrayFinder extends WebdriverWebElement {
* @returns {Array.<ElementFinder>} Return a promise, which resolves to a list
* of ElementFinders specified by the locator.
*/
asElementFinders_(): wdpromise.Promise<any> {
asElementFinders_(): wdpromise.Promise<ElementFinder[]> {
return this.getWebElements().then((arr: WebElement[]) => {
return arr.map((webElem: WebElement) => {
return ElementFinder.fromWebElement_(this.browser_, webElem, this.locator_);
Expand Down Expand Up @@ -521,9 +521,9 @@ export class ElementArrayFinder extends WebdriverWebElement {
* @returns {!webdriver.promise.Promise} A promise which will resolve to
* an array of ElementFinders represented by the ElementArrayFinder.
*/
then(
fn?: (value: ElementFinder[]) => any | wdpromise.IThenable<any>,
errorFn?: (error: any) => any): wdpromise.Promise<any> {
then<T>(
fn?: (value: ElementFinder[]) => T | wdpromise.IThenable<T>,
errorFn?: (error: any) => any): wdpromise.Promise<T> {
if (this.actionResults_) {
return this.actionResults_.then(fn, errorFn);
} else {
Expand Down Expand Up @@ -619,7 +619,7 @@ export class ElementArrayFinder extends WebdriverWebElement {
* @returns {!webdriver.promise.Promise} A promise that resolves to an array
* of values returned by the map function.
*/
map(mapFn: (elementFinder?: ElementFinder, index?: number) => any): wdpromise.Promise<any> {
map<T>(mapFn: (elementFinder?: ElementFinder, index?: number) => T): wdpromise.Promise<T> {
return this.asElementFinders_().then((arr: ElementFinder[]) => {
let list = arr.map((elementFinder?: ElementFinder, index?: number) => {
let mapResult = mapFn(elementFinder, index);
Expand Down