Created
December 19, 2018 01:40
-
-
Save rctay/df8c2190993ca976a31e7ec49c9a1389 to your computer and use it in GitHub Desktop.
Explicit typing for merging 2 objects/decorating in TypeScript with intersection types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { $ } from 'protractor'; | |
export interface ChangePasswordDialog { | |
currentPasswordField: ElementFinder; | |
incorrectPasswordError: ElementFinder; | |
submitButton: ElementFinder; | |
} | |
export class SettingsPage extends AppPage { | |
get changePasswordDialog(): ElementFinder & ChangePasswordDialog { | |
const func: ElementFinder = $('app-reset-password-dialog'); | |
const addOns: ChangePasswordDialog = { | |
get currentPasswordField() { return func.$('input[name="currentPassword"]'); }, | |
get incorrectPasswordError() { return func.$('.reset_password__incorrect-password'); }, | |
get submitButton() { return func.$('.password-dialog__confirm-button'); }, | |
}; | |
return Object.assign(func, addOns); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment