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

Type safety for datatable #463

Closed
xuanvinhvu opened this issue Oct 29, 2020 · 12 comments
Closed

Type safety for datatable #463

xuanvinhvu opened this issue Oct 29, 2020 · 12 comments

Comments

@xuanvinhvu
Copy link

I would like to have type safety for dataTable.

Given("the user logged into to the tenant portal", (dataTable: DataTable) => {
   ...
});

The dataTable object seems to come from cucumber.js. I'm assuming there is no typescript definition for it?

@badeball
Copy link
Owner

I'm assuming there is no typescript definition for it?

Not in the version of cucumber that the preprocessor currently depends on.

@xuanvinhvu
Copy link
Author

It's true that cucumber.js doesn't have type DataTable until version 7, but we should be able to use TableDefinition instead?

7.0.0-rc.0 (2020-09-14)
Starting with version 7, the npm module has been changed from cucumber to @cucumber/cucumber

Migration guide:

npm uninstall cucumber
npm install --save-dev @cucumber/cucumber
require/import @cucumber/cucumber instead of cucumber
TypeScript
Replace TableDefinition with DataTable

Should it be expose through @types/cypress-cucumber-preprocessor?

@badeball
Copy link
Owner

badeball commented Oct 29, 2020

Should it be expose through @types/cypress-cucumber-preprocessor?

Yes, I absolutely think it should, provided that we produce instances of it (which we do).

@xuanvinhvu
Copy link
Author

Should it be expose through @types/cypress-cucumber-preprocessor?

Yes, I absolutely think it should, provided that we produce instances of it (which we do).

I ran into this #385 while I was looking to add TableDefinition to @types/cypress-cucumber-preprocessor

It looks like @lgandecki made a decision to update the types in cypress-cucumber-preprocessor instead of @types/cypress-cucumber-preprocessor. Reading the thread there was a preference to have a single source of truth. Considering the history is this still the way to go?

@badeball
Copy link
Owner

Considering the history is this still the way to go?

Two sources of truth? No. Let me be frank here and excuse my lack of patience. I dislike our use of DefinitelyTyped. In fact, I fact, despise it. I understand the motivation behind DefinitelyTyped and why is it necessary, but I wish it wasn't like that. I would like for us to ship our own types, which would be correlated to version and not be subject to a mismatch game that there currently is.

I wish I could say more in response, something more useful. Truth is that we're going to have to make a decision about the way forward, ref. #322.

@lgandecki
Copy link
Collaborator

I agree, having two sources of truth is awful and being able to just emit correct types based on code would (and I hope will) be the way to go.

@xuanvinhvu
Copy link
Author

What am hearing from you guys is adding TableDefinition to @types/cypress-cucumber-preprocessor is not the correct long term solution but what about using it as a short term solution?

@jonsamwell
Copy link

Any progress with this?

@swiec-qualio
Copy link

Same question - any progress here? Would be great to be able to have it typed.

@badeball
Copy link
Owner

Due to personal reasons, the previous maintainers of this package are stepping down and handing the reigns over to me, a long-time contributor to the project and a user of it myself. This is a responsibility I'm very excited about. Furthermore, I'd like to thank @lgandecki ++ for all the work that they've done so far.

Read more about the transfer of ownership here.

The repository has however moved and all outstanding issues are being closed. This is not a reflection of the perceived importance of your reported issue. However, if after upgrading to the new version, you still find there to be an issue, feel free to open up another ticket or comment below. Please make sure to read CONTRIBUTING.md before doing so.

@RicFer01
Copy link

RicFer01 commented Feb 9, 2023

Sorry, I know it's closed, but is the conclusion that it's not possible to type datatable?

@badeball
Copy link
Owner

badeball commented Feb 9, 2023

No, it’s typed since the rewrite. Take a look at the exported members.

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

No branches or pull requests

6 participants