fix(unify): improve dev server config ergonomics (#19957)

This commit is contained in:
Ben Alman
2022-01-28 21:45:28 -05:00
committed by GitHub
parent 03e428f457
commit 6a402a7076
6 changed files with 22 additions and 23 deletions
+7 -1
View File
@@ -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'
@@ -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>>
}
/**
+3 -3
View File
@@ -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
@@ -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;
+3 -3
View File
@@ -1,4 +1,4 @@
declare namespace legacyDevServer {
declare namespace CypressCracoDevServer {
interface CypressCracoDevServerConfig {
/**
* The object exported of your craco.config.js file
@@ -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;
+3 -3
View File
@@ -1,4 +1,4 @@
declare namespace legacyDevServer {
declare namespace CypressWebpackDevServer {
interface CypressWebpackDevServerConfig {
/**
* Location of the weppack.config Cypress should use
@@ -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;
+3 -10
View File
@@ -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
@@ -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;
+3 -3
View File
@@ -1,4 +1,4 @@
declare namespace legacyDevServer {
declare namespace CypressCRADevServer {
interface CypressCRADevServerConfig {
/**
* Location of the weppack.config Cypress should use
@@ -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;