-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
chore: Add dtslint and Cypress static types #1044
chore: Add dtslint and Cypress static types #1044
Conversation
"dependencies": { | ||
"@cypress/listr-verbose-renderer": "0.4.1", | ||
"@cypress/xvfb": "1.0.4", | ||
"@types/blob-util": "1.3.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure these have to be normal dependencies for downstream projects. I haven't actually deployed and linked as devDependencies
, but from other testing the types will fail and fallback to any
if the types can't be found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I think they will have to be included then.
cli/types/index.d.ts
Outdated
*/ | ||
requestTimeout: number; | ||
/** | ||
* Time, in milliseconds, to wait until a response in a [cy.request()](https://on.cypress.io/api/request), [cy.wait()](https://on.cypress.io/api/wait), [cy.fixture()](https://on.cypress.io/api/fixture), [cy.getCookie()](https://on.cypress.io/api/getcookie), [cy.getCookies()](https://on.cypress.io/api/getcookies), [cy.setCookie()](https://on.cypress.io/api/setcookie), [cy.clearCookie()](https://on.cypress.io/api/clearcookie), [cy.clearCookies()](https://on.cypress.io/api/clearcookies), and [cy.screenshot()](https://on.cypress.io/api/screenshot) commands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't have to use https://on.cypress.io/api/request
just https://on.cypress.io/request
would be better!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing.
There are a lot of other URLs with the extra /api
in the URL. I can update those URLs as well.
cli/types/index.d.ts
Outdated
@@ -910,6 +927,165 @@ declare namespace Cypress { | |||
cancable?: boolean; | |||
} | |||
|
|||
interface ConfigOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we allow all options to be optional using Partial<ConfigOptions>
? that is pretty slick if true!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Partial
is a mapped type that iterates over the keys and makes each optional. It is really useful if you want an interface without optional parameters and make them optional for things like default overrides.
Mapped types are pretty cool. TypeScript lib.d.ts
defines a few globally: https://github.com/Microsoft/TypeScript/blob/master/lib/lib.d.ts#L1329
@NicholasBoll do you see the broken build in https://circleci.com/gh/cypress-io/cypress/7682 ? since you moved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I loved the smart definitions, you are much better at TypeScript than I am!
Small requests to change things, mostly to make sure the build passes through.
I'll fix the build issue. I'll use #979 to make sure get all the path changes corrected. Types aren't required to go into a |
I'll also make sure the package contains all the type definitions using |
I've noticed that JS files don't have semicolons. I think the TSLint and type definitions shouldn't have them either. |
all great stuff @NicholasBoll ! hope to merge it |
I've removed semicolons from the type definitions files. Removing semicolons from @bahmutov You'll have to let me know if that's okay. If not, I can remove the semicolon removal as part of a separate PR. |
I've added type tests: |
I have also run |
Love it, locally checks out! |
Fixes #1046 |
This is a break-apart of more completed work. Info can be found at #1040
This particular PR closes #1046
Included in this PR:
types
perdtslint
recommendations (there are a few types files)Cypress
aliased objects likeCypress._
,Cypress.$
, etc.dtslint
to unit test task. Not sure the most appropriate spotI didn't actually add any type tests as all my tests are verifying the completed type definitions.