Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cdk/testing): strongly type return value of TestElement.getProperty #22918

Merged
merged 1 commit into from Jul 2, 2021

Conversation

Copy link
Member

@crisbeto crisbeto commented Jun 8, 2021

Allows for the return value of TestElement.getProperty to be typed strongly through a generic parameter.

@crisbeto crisbeto added P3 target: patch labels Jun 8, 2021
@crisbeto crisbeto requested a review from mmalerba Jun 8, 2021
@google-cla google-cla bot added the cla: yes label Jun 8, 2021
Copy link
Contributor

@mmalerba mmalerba left a comment

LGTM

@@ -206,8 +206,8 @@ export class ProtractorElement implements TestElement {
}

/** Gets the value of a property of an element. */
async getProperty(name: string): Promise<any> {
return browser.executeScript(`return arguments[0][arguments[1]]`, this.element, name);
async getProperty<T = any>(name: string): Promise<T> {
Copy link
Contributor

@mmalerba mmalerba Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we'd make the default unknown but I guess maybe that's too breaking?

Copy link
Member Author

@crisbeto crisbeto Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I suspect that unknown will be breaking. I doubt that getProperty is used too often since most of the time you can get the same information through getAttribute.

@crisbeto crisbeto added the merge ready label Jun 9, 2021
Copy link
Member

@jelbourn jelbourn left a comment

LGTM, but we should see if we can change this to unknown for v13

Copy link
Member

@devversion devversion left a comment

LGTM. Agreed on unknown being better in the future; we could have a migration for that.

async getProperty(name: string): Promise<any> {
return browser.executeScript(`return arguments[0][arguments[1]]`, this.element, name);
async getProperty<T = any>(name: string): Promise<T> {
return browser.executeScript<T>(`return arguments[0][arguments[1]]`, this.element, name);
Copy link
Contributor

@mmalerba mmalerba Jun 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that google's internal typings do not support a generic version of executeScript can you change this to return browser.executeScript(...) as any

@mmalerba mmalerba removed the merge ready label Jun 17, 2021
Allows for the return value of `TestElement.getProperty` to be typed strongly through a generic parameter.
@crisbeto
Copy link
Author

@crisbeto crisbeto commented Jun 17, 2021

Done. Also rebased.

@crisbeto crisbeto added the merge ready label Jun 17, 2021
@andrewseguin andrewseguin merged commit b682f84 into angular:master Jul 2, 2021
16 checks passed
andrewseguin pushed a commit that referenced this issue Jul 2, 2021
…ty (#22918)

Allows for the return value of `TestElement.getProperty` to be typed strongly through a generic parameter.

(cherry picked from commit b682f84)
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Aug 2, 2021

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes merge ready P3 target: patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants