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

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

Open
DetachHead opened this issue Nov 25, 2021 · 1 comment
Labels
types ES modules types (recommended)

Comments

@DetachHead
Copy link

DetachHead commented Nov 25, 2021

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 () {},
                })
            },
        },
    },
})
@DetachHead DetachHead changed the title @sapui5/ts-types - PageObjectDefinition.assertions & assertions function types should have a this parameter @sapui5/ts-types - PageObjectDefinition.actions & assertions function types should have a this parameter Nov 25, 2021
@petermuessig petermuessig added the legacy ts-types (with globals) Related to legacy Global types (deprecated) label Nov 28, 2021
@petermuessig
Copy link
Contributor

Same like #306 - testing related code wasn't in focus of TS API support so far.

@DetachHead DetachHead changed the title @sapui5/ts-types - PageObjectDefinition.actions & assertions function types should have a this parameter @sapui5/ts-types-esm - PageObjectDefinition.actions & assertions function types should have a this parameter Nov 29, 2021
@petermuessig petermuessig added types ES modules types (recommended) and removed legacy ts-types (with globals) Related to legacy Global types (deprecated) labels Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types ES modules types (recommended)
Projects
None yet
Development

No branches or pull requests

2 participants