-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Allow plugin authors to extend the Cypress config types #22127
Comments
I tried to extend the return type of // my-package/types/index.d.ts
declare global {
namespace Cypress {
interface ConfigOptions {
requestBaseUrl?: string;
}
}
} As a workaround, you could export your own interface MyConfigOptions extends Cypress.ConfigOptions {
requestBaseUrl: string;
}
const myDefineConfig = (config: MyConfigOptions): MyConfigOptions =>
config;
// usage
export default myDefineConfig({ ... }); |
That's a better workaround than the ones I had up to now, but is still limited in that only 1 plugin can change the config types. In any case, progress :) Sounds like it would be a relatively easy fix on the Cypress side to make |
Hey @Lakitna, we don't currently have this prioritized but we would absolutely accept a PR that updates the types to work like you've described. |
What would you like?
The ability for extension authors to extend the types used in the
defineConfig
function when configuring Cypress viacypress.config.ts
(or, to a lesser extent,cypress.config.js
).Why is this needed?
I am the author of
cypress-commands
which adds a few new commands and extends some others.One of the extended commands also adds a new property to the config file. In this case, the extended
cy.request()
uses therequestBaseUrl
config property. Details on the command: https://github.com/Lakitna/cypress-commands/blob/develop/docs/request.mdI have tried to extend it using the same approach as with adding commands to the types. It does not work as-is, the type validation keeps throwing errors.
Other
To make things seamless for users, I want to refrain from using/recommending workarounds like:
defineConfig
. This skips the type checks.cypress.config.js
instead of.ts
. This skips the type checks.The text was updated successfully, but these errors were encountered: