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

fix: Introduce CypressCommandLine namespace to type NPM module api #8096

Merged
merged 3 commits into from
Jul 29, 2020

Conversation

sainthkh
Copy link
Contributor

@sainthkh sainthkh commented Jul 28, 2020

User facing changelog

Moved types inside 'cypress' module to CypressCmd namespace to make them usable.

Additional details

  • Why was this change necessary? Types defined in cypress-npm-api.d.ts weren't usable for users who want to create their own TypeScript commands.
  • What is affected by this change? N/A
  • Any implementation details to explain? N/A

How has the user experience changed?

N/A

PR Tasks

  • Have tests been added/updated?
  • Has the original issue been tagged with a release in ZenHub?
  • [N/A] Has a PR for user-facing changes been opened in cypress-documentation?
  • [N/A] Have API changes been updated in the type definitions?
  • [N/A] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 28, 2020

Thanks for taking the time to open a PR!

@sainthkh sainthkh marked this pull request as ready for review July 28, 2020 01:56
@flotwig
Copy link
Contributor

flotwig commented Jul 28, 2020

@sainthkh does this make the types exported from the NPM package, or does it only create an ambient global namespace CypressCmd?

@@ -6,7 +6,7 @@
// in the future the NPM module itself will be in TypeScript
// but for now describe it as an ambient module

declare module 'cypress' {
declare namespace CypressCmd {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be better named CypressCommandLine

@sainthkh
Copy link
Contributor Author

@flotwig We cannot export interfaces in the module because there is export = cypress. Because of that, I had to create ambient global namespace, CypressCommandLine.

@sainthkh sainthkh changed the title fix: Introduce CypressCmd namespace to make cmd-related types usable fix: Introduce CypressCommandLine namespace to make cmd-related types usable Jul 29, 2020
@bahmutov bahmutov self-requested a review July 29, 2020 17:48
Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, tests are passing, thanks for updating the name

@bahmutov bahmutov changed the title fix: Introduce CypressCommandLine namespace to make cmd-related types usable fix: Introduce CypressCommandLine namespace to type NPM module api Jul 29, 2020
@bahmutov bahmutov merged commit 15c71c5 into cypress-io:develop Jul 29, 2020
@jennifer-shehane
Copy link
Member

Should this be documented somewhere in our TypeScript docs? @sainthkh

@sainthkh
Copy link
Contributor Author

sainthkh commented Aug 3, 2020

How about adding types for module api section and an example like below?

cypress.run({ env })
    .then((result: CypressCommandLine.CypressRunResult) => {
      logger.info(result.totalTests);
      logger.info(result.totalFailed);
    });

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

Successfully merging this pull request may close these issues.

Types not exported in .d.ts
4 participants