`@sapui5/ts-types-esm` - `PageObjectDefinition.actions` & `assertions` function types should have a `this` parameter

Open
#307 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
tooling

Research direction

Start at the @sapui5/ts-types-esm definition of PageObjectDefinition and inspect the actions and assertions function types. Compare them with the Opa5.createPageObjects example linked in the issue, then verify that its this.waitFor call compiles once the this type is represented.

Written by the indexing model from the issue text.

Description

types
export type PageObjectDefinition = {
    //...
    actions?: Record<string, (this: Opa5) => void>;
    assertions?: Record<string, (this: Opa5) => void>;
}

otherwise this example won't compile bcause the this type is not defined:

Opa5.createPageObjects({
    onTheAppPage: {
        actions: {},

        assertions: {
            iShouldSeeTheApp: function () {
                // error: Cannot invoke an object which is possibly 'undefined'
                this.waitFor({
                    id: 'myButton',
                    actions: function () {},
                    success: function () {},
                })
            },
        },
    },
})
Dominant language
TypeScript
Stars
213
Forks
35
Avg merge
37m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from UI5/typescript

All issues in UI5/typescript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.