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(unify): improve dev server config ergonomics #19957

Merged
merged 5 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/// <reference path="./cypress-npm-api.d.ts" />
/// <reference path="./cypress-eventemitter.d.ts" />

// The new Awaited type added in 4.5 would work here, but we seem to need to
// support older versions of Typescript
type AwaitedLike<T> = T extends PromiseLike<infer U>
? { 0: AwaitedLike<U>; 1: U }[U extends PromiseLike<any> ? 0 : 1]
: T

declare namespace Cypress {
type FileContents = string | any[] | object
type HistoryDirection = 'back' | 'forward'
Expand Down Expand Up @@ -2988,7 +2994,7 @@ declare namespace Cypress {
type DevServerFn<ComponentDevServerOpts = any> = (cypressConfig: DevServerConfig, devServerConfig: ComponentDevServerOpts) => ResolvedDevServerConfig | Promise<ResolvedDevServerConfig>
interface ComponentConfigOptions<ComponentDevServerOpts = any> extends CoreConfigOptions {
devServer: Promise<{ devServer: DevServerFn<ComponentDevServerOpts>}> | { devServer: DevServerFn<ComponentDevServerOpts> } | DevServerFn<ComponentDevServerOpts>
devServerConfig?: ComponentDevServerOpts | Promise<ComponentDevServerOpts>
devServerConfig?: ComponentDevServerOpts | AwaitedLike<Promise<ComponentDevServerOpts>>
}

/**
Expand Down
6 changes: 3 additions & 3 deletions npm/react/plugins/babel/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Configuration } from "webpack";

declare namespace legacyDevServer {
declare namespace CypressBabelDevServer {
interface CypressBabelDevServerConfig {
/**
* Allows to adjust the webpackConfig that our dev-server will use
Expand Down Expand Up @@ -31,6 +31,6 @@ declare namespace legacyDevServer {
* @param config comes from the argument of the `pluginsFile` function
* @param devServerConfig additional config object (create an empty object it to see how to use it)
*/
declare function legacyDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, devServerConfig?: legacyDevServer.CypressBabelDevServerConfig): void
declare function CypressBabelDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, devServerConfig?: CypressBabelDevServer.CypressBabelDevServerConfig): void

export = legacyDevServer;
export = CypressBabelDevServer;
6 changes: 3 additions & 3 deletions npm/react/plugins/craco/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare namespace legacyDevServer {
declare namespace CypressCracoDevServer {
interface CypressCracoDevServerConfig {
/**
* The object exported of your craco.config.js file
Expand Down Expand Up @@ -27,6 +27,6 @@ declare namespace legacyDevServer {
* @param config comes from the argument of the `pluginsFile` function
* @param cracoConfig the object exported of your craco.config.js file
*/
declare function legacyDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, cracoConfig: any): void
declare function CypressCracoDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, cracoConfig: any): void

export = legacyDevServer;
export = CypressCracoDevServer;
6 changes: 3 additions & 3 deletions npm/react/plugins/load-webpack/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare namespace legacyDevServer {
declare namespace CypressWebpackDevServer {
interface CypressWebpackDevServerConfig {
/**
* Location of the weppack.config Cypress should use
Expand Down Expand Up @@ -27,6 +27,6 @@ declare namespace legacyDevServer {
* @param config comes from the argument of the `pluginsFile` function
* @param devServerConfig additional config object (create an empty object to see how to use it)
*/
declare function legacyDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, devServerConfig?: legacyDevServer.CypressWebpackDevServerConfig): void
declare function CypressWebpackDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, devServerConfig?: CypressWebpackDevServer.CypressWebpackDevServerConfig): void

export = legacyDevServer;
export = CypressWebpackDevServer;
13 changes: 3 additions & 10 deletions npm/react/plugins/next/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/**
* Sets up a Cypress component testing environment for your NextJs application
* @param on comes from the argument of the `pluginsFile` function
* @param config comes from the argument of the `pluginsFile` function
*/
declare function legacyDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions): void

declare namespace legacyDevServer {
declare namespace CypressNextDevServer {
interface CypressNextDevServerConfig {
/**
* Path to an index.html file that will serve as the template in
Expand All @@ -28,6 +21,6 @@ declare namespace legacyDevServer {
* @param config comes from the argument of the `pluginsFile` function
* @param devServerConfig additional config object (create an empty object to see how to use it)
*/
declare function legacyDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, devServerConfig?: legacyDevServer.CypressNextDevServerConfig): void
declare function CypressNextDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, devServerConfig?: CypressNextDevServer.CypressNextDevServerConfig): void

export = legacyDevServer;
export = CypressNextDevServer;
6 changes: 3 additions & 3 deletions npm/react/plugins/react-scripts/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare namespace legacyDevServer {
declare namespace CypressCRADevServer {
interface CypressCRADevServerConfig {
/**
* Location of the weppack.config Cypress should use
Expand Down Expand Up @@ -27,6 +27,6 @@ declare namespace legacyDevServer {
* @param config comes from the argument of the `pluginsFile` function
* @param devServerConfig additional config object (create an empty object to see how to use it)
*/
declare function legacyDevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, devServerConfig?: legacyDevServer.CypressCRADevServerConfig): void
declare function CypressCRADevServer(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, devServerConfig?: CypressCRADevServer.CypressCRADevServerConfig): void

export = legacyDevServer;
export = CypressCRADevServer;