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

World is not properly typed in the latest wersion #1667

Closed
MilanJimi opened this issue May 7, 2021 · 3 comments · Fixed by #1690
Closed

World is not properly typed in the latest wersion #1667

MilanJimi opened this issue May 7, 2021 · 3 comments · Fixed by #1690
Assignees
Labels
🐛 bug Defect / Bug ✅ accepted The core team has agreed that it is a good idea to fix this

Comments

@MilanJimi
Copy link

MilanJimi commented May 7, 2021

Node v12.19.0, TypeScript v4.2.4, @cucumber/cucumber v7.2.1, Ubuntu v20.04

I can no longer use World in my tests, because this is no longer typed inside the Given/When/Then functions, instead defaulting to being typed as any.

If I downgrade to version cucumber v7.0.0-rc.0, this is properly typed as World.
image

image

@davidjgoss davidjgoss added the 🐛 bug Defect / Bug label May 7, 2021
@davidjgoss davidjgoss self-assigned this May 7, 2021
@davidjgoss davidjgoss added the ✅ accepted The core team has agreed that it is a good idea to fix this label May 7, 2021
@davidjgoss
Copy link
Contributor

davidjgoss commented May 7, 2021

Thanks for raising @MilanJimi, I can reproduce this and will fix.

In the meantime as a workaround, you can specify the type of this by prepending it to the function's arguments, e.g.:

import {Then, World} from '@cucumber/cucumber';

Then('the test runs with string parameter {string}', async function(this: World, parameter: string) {
    this.driver.close()
})

@charlierudolph
Copy link
Member

I'm surprised this worked this in step definitions was ever auto-typed as World. @davidjgoss do you know how this was supported before / what changed that broke it?

@davidjgoss
Copy link
Contributor

@charlierudolph no I don’t think it ever worked since our refactor to TypeScript. The second screenshot above is from v6 with (presumably) the types from DefinitelyTyped, which did type this as World - which was just an alias for an object with arbitrary props.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug ✅ accepted The core team has agreed that it is a good idea to fix this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants