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

"parent" property is missing for Typescript interface within a Section #4360

Open
MateoAgudGarcia opened this issue Jan 29, 2025 · 0 comments

Comments

@MateoAgudGarcia
Copy link

MateoAgudGarcia commented Jan 29, 2025

Description

According to the conversation in the Discord server, when trying to use with Typescript the parent of this, understanding that inside a section, the interface is EnhancedSectionInstance, therefore when performing a this.parent it automatically generates an error, since it is understood that the parent is an any.
Image

Suggested solution

Understanding that the parent must have the interface of a section since it is understood to be encapsulating its child, parent should have the EnhancedSectionInstance interface.
Therefore when reviewing the EnhancedPageObjectSharedFields interface, something like this should be added inside its structure

interface EnhancedPageObjectSharedFields<
  Commands = {},
  Elements = {},
  Sections extends Record<string, PageObjectSection> = {},
  Props = {},
  URL = string
> {
...

  /**
  * Parent section instance.
  */
  parent: EnhancedSectionInstance;

...
};

In this way, and testing it locally, this parent property works perfectly, leaving everything in a cleaner way and giving better options to the modularity.

Alternatives / Workarounds

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant