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

refactor typedefs for cy #3499

Merged
merged 16 commits into from
Jul 15, 2019
Merged

refactor typedefs for cy #3499

merged 16 commits into from
Jul 15, 2019

Conversation

kuceb
Copy link
Contributor

@kuceb kuceb commented Feb 15, 2019

for users/plugin-authors who just want to extend cy and not the Cypress.Chainable

for example, I want to do this:

namespace Cypress {
  interface cy {
    retries: Mocha.ISuiteCallbackContext.retries
  }
}

to indicate I can only access my property on the parent cy

tasks

@kuceb kuceb requested a review from bahmutov February 15, 2019 22:53
@bahmutov
Copy link
Contributor

@bkucera can you add a dtslint test if possible for this? That checks that someone can actually extend cy object without extending Chainable interface?

@@ -4237,6 +4237,8 @@ declare namespace Cypress {
// Diff taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
type Diff<T extends string, U extends string> = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

interface cy extends Chainable<undefined> {}
Copy link
Contributor

Choose a reason for hiding this comment

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

can this interface cy be documented please?

* Unfortunately we cannot test that vendor types located in node_modules are working
* since those are copied as part of the deploy process
*
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs more documentation - this is what someone who writes a new command or adds a property to cy global object should do right. So we should describe this better, even for ourselves.

Also, the formatting is all off below, maybe it needs a prettier ...

bahmutov
bahmutov previously approved these changes Jul 3, 2019
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.

@bkucera I love the refactoring and the type test, and this seems like the simplest way to extend Cypress with a custom command, but I would love to see more JSDoc comments before merging it

@@ -16,6 +16,7 @@
"check-deps-pre": "npm run check-deps -- --prescript",
"dtslint": "dtslint types",
"postinstall": "node ./scripts/post-install.js",
"lint": "bin-up eslint --fix *.js scripts/*.js bin/* lib/*.js lib/**/*.js test/*.js test/**/*.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the right command now? to lint?

@bahmutov
Copy link
Contributor

I have removed a few @example in JSDoc because seems VSCode has changed how it shows intellisense popups, and the examples really looked bad

with @example

Screen Shot 2019-07-12 at 1 49 30 PM

without @example

Screen Shot 2019-07-12 at 1 49 38 PM

bahmutov
bahmutov previously approved these changes Jul 12, 2019
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

@bahmutov
Copy link
Contributor

I have tried this change against cypress-example-todomvc custom commands, seems still to pass just fine

@emilyrohrbough emilyrohrbough deleted the typings-fix branch August 1, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide example how one can add custom commands and properties to cy object
3 participants