diff --git a/packages/driver/cypress/integration/commands/net_stubbing_spec.ts b/packages/driver/cypress/integration/commands/net_stubbing_spec.ts index 8dac97dcb092..de9fe72aa0e6 100644 --- a/packages/driver/cypress/integration/commands/net_stubbing_spec.ts +++ b/packages/driver/cypress/integration/commands/net_stubbing_spec.ts @@ -1,5 +1,5 @@ import { getDisplayUrlMatcher } from '@packages/driver/src/cy/net-stubbing/route-matcher-log' -import { RouteMatcherOptions } from '@packages/net-stubbing/lib/external-types' +import type { RouteMatcherOptions } from '@packages/net-stubbing/lib/external-types' const testFail = (cb, expectedDocsUrl = 'https://on.cypress.io/intercept') => { cy.on('fail', (err) => { diff --git a/packages/driver/src/cy/keyboard.ts b/packages/driver/src/cy/keyboard.ts index 1c1ac61cd988..2a87f04d9f1b 100644 --- a/packages/driver/src/cy/keyboard.ts +++ b/packages/driver/src/cy/keyboard.ts @@ -8,7 +8,7 @@ import * as $dom from '../dom' import * as $document from '../dom/document' import * as $elements from '../dom/elements' // eslint-disable-next-line no-duplicate-imports -import { HTMLTextLikeElement } from '../dom/elements' +import type { HTMLTextLikeElement } from '../dom/elements' import * as $selection from '../dom/selection' import $utils from '../cypress/utils' import $window from '../dom/window' @@ -689,9 +689,7 @@ export interface typeOptions { } export class Keyboard { - constructor (private state: State) { - null - } + constructor (private state: State) {} type (opts: typeOptions) { const options = _.defaults({}, opts, { diff --git a/packages/driver/src/cy/net-stubbing/aliasing.ts b/packages/driver/src/cy/net-stubbing/aliasing.ts index dc24b6f88717..2f01c503e668 100644 --- a/packages/driver/src/cy/net-stubbing/aliasing.ts +++ b/packages/driver/src/cy/net-stubbing/aliasing.ts @@ -1,5 +1,5 @@ import _ from 'lodash' -import { +import type { Interception, } from './types' diff --git a/packages/driver/src/cy/net-stubbing/events/after-response.ts b/packages/driver/src/cy/net-stubbing/events/after-response.ts index 8a060b0116b5..edf989dee84c 100644 --- a/packages/driver/src/cy/net-stubbing/events/after-response.ts +++ b/packages/driver/src/cy/net-stubbing/events/after-response.ts @@ -1,5 +1,5 @@ -import { CyHttpMessages } from '@packages/net-stubbing/lib/types' -import { HandlerFn } from '.' +import type { CyHttpMessages } from '@packages/net-stubbing/lib/types' +import type { HandlerFn } from '.' import { parseJsonBody } from './utils' export const onAfterResponse: HandlerFn = async (Cypress, frame, userHandler, { getRequest, getRoute }) => { diff --git a/packages/driver/src/cy/net-stubbing/events/before-request.ts b/packages/driver/src/cy/net-stubbing/events/before-request.ts index 5b35bdc5ffba..3c3e839fe0cb 100644 --- a/packages/driver/src/cy/net-stubbing/events/before-request.ts +++ b/packages/driver/src/cy/net-stubbing/events/before-request.ts @@ -12,9 +12,9 @@ import { parseStaticResponseShorthand, } from '../static-response-utils' import * as $errUtils from '../../../cypress/error_utils' -import { HandlerFn, HandlerResult } from '.' +import type { HandlerFn, HandlerResult } from '.' import Bluebird from 'bluebird' -import { NetEvent } from '@packages/net-stubbing/lib/types' +import type { NetEvent } from '@packages/net-stubbing/lib/types' import Debug from 'debug' const debug = Debug('cypress:driver:net-stubbing:events:before-request') diff --git a/packages/driver/src/cy/net-stubbing/events/index.ts b/packages/driver/src/cy/net-stubbing/events/index.ts index 671a1b37091a..37086ee24967 100644 --- a/packages/driver/src/cy/net-stubbing/events/index.ts +++ b/packages/driver/src/cy/net-stubbing/events/index.ts @@ -1,4 +1,4 @@ -import { Route, Interception, StaticResponse, NetEvent } from '../types' +import type { Route, Interception, StaticResponse, NetEvent } from '../types' import { onBeforeRequest } from './before-request' import { onResponse } from './response' import { onAfterResponse } from './after-response' diff --git a/packages/driver/src/cy/net-stubbing/events/network-error.ts b/packages/driver/src/cy/net-stubbing/events/network-error.ts index 0a632c4acd8f..c806d556ef4a 100644 --- a/packages/driver/src/cy/net-stubbing/events/network-error.ts +++ b/packages/driver/src/cy/net-stubbing/events/network-error.ts @@ -1,7 +1,7 @@ import { get } from 'lodash' -import { CyHttpMessages } from '@packages/net-stubbing/lib/types' +import type { CyHttpMessages } from '@packages/net-stubbing/lib/types' import * as $errUtils from '../../../cypress/error_utils' -import { HandlerFn } from '.' +import type { HandlerFn } from '.' export const onNetworkError: HandlerFn = async (Cypress, frame, userHandler, { getRequest, getRoute }) => { const request = getRequest(frame.subscription.routeId, frame.requestId) diff --git a/packages/driver/src/cy/net-stubbing/events/response.ts b/packages/driver/src/cy/net-stubbing/events/response.ts index 846799848257..c062f56a5563 100644 --- a/packages/driver/src/cy/net-stubbing/events/response.ts +++ b/packages/driver/src/cy/net-stubbing/events/response.ts @@ -10,7 +10,7 @@ import { STATIC_RESPONSE_KEYS, } from '../static-response-utils' import * as $errUtils from '../../../cypress/error_utils' -import { HandlerFn, HandlerResult } from '.' +import type { HandlerFn, HandlerResult } from '.' import Bluebird from 'bluebird' import { parseJsonBody, stringifyJsonBody } from './utils' diff --git a/packages/driver/src/cy/net-stubbing/events/utils.ts b/packages/driver/src/cy/net-stubbing/events/utils.ts index 339d0bd082fa..fb9e0c59abc9 100644 --- a/packages/driver/src/cy/net-stubbing/events/utils.ts +++ b/packages/driver/src/cy/net-stubbing/events/utils.ts @@ -1,5 +1,5 @@ import { find } from 'lodash' -import { CyHttpMessages } from '@packages/net-stubbing/lib/types' +import type { CyHttpMessages } from '@packages/net-stubbing/lib/types' export function hasJsonContentType (headers: { [k: string]: string | string[] }) { const contentType = find(headers, (v, k) => /^content-type$/i.test(k)) diff --git a/packages/driver/src/cy/net-stubbing/route-matcher-log.ts b/packages/driver/src/cy/net-stubbing/route-matcher-log.ts index 33683a57adb9..7fb3d7d8a77f 100644 --- a/packages/driver/src/cy/net-stubbing/route-matcher-log.ts +++ b/packages/driver/src/cy/net-stubbing/route-matcher-log.ts @@ -1,6 +1,6 @@ import _ from 'lodash' -import { +import type { RouteMatcherOptions, StaticResponse, } from '@packages/net-stubbing/lib/types' diff --git a/packages/driver/src/cy/net-stubbing/static-response-utils.ts b/packages/driver/src/cy/net-stubbing/static-response-utils.ts index 7e5961e7af45..de422cf06dda 100644 --- a/packages/driver/src/cy/net-stubbing/static-response-utils.ts +++ b/packages/driver/src/cy/net-stubbing/static-response-utils.ts @@ -1,6 +1,6 @@ import _ from 'lodash' -import { +import type { StaticResponse, BackendStaticResponseWithArrayBuffer, FixtureOpts, diff --git a/packages/driver/src/cy/net-stubbing/wait-for-route.ts b/packages/driver/src/cy/net-stubbing/wait-for-route.ts index fb3d167658ae..96321920d7ff 100644 --- a/packages/driver/src/cy/net-stubbing/wait-for-route.ts +++ b/packages/driver/src/cy/net-stubbing/wait-for-route.ts @@ -1,4 +1,4 @@ -import { +import type { Interception, InterceptionState, } from './types' diff --git a/packages/driver/src/cypress/proxy-logging.ts b/packages/driver/src/cypress/proxy-logging.ts index 2a6ff6474f53..9df81f560da1 100644 --- a/packages/driver/src/cypress/proxy-logging.ts +++ b/packages/driver/src/cypress/proxy-logging.ts @@ -1,5 +1,5 @@ -import { Interception, Route } from '@packages/net-stubbing/lib/types' -import { BrowserPreRequest, BrowserResponseReceived, RequestError } from '@packages/proxy/lib/types' +import type { Interception, Route } from '@packages/net-stubbing/lib/types' +import type { BrowserPreRequest, BrowserResponseReceived, RequestError } from '@packages/proxy/lib/types' import * as $errUtils from './error_utils' import Debug from 'debug' diff --git a/packages/driver/src/cypress/resolvers.ts b/packages/driver/src/cypress/resolvers.ts index 9c49f032d8a1..cc745e564654 100644 --- a/packages/driver/src/cypress/resolvers.ts +++ b/packages/driver/src/cypress/resolvers.ts @@ -1,5 +1,5 @@ import _ from 'lodash' -import $Cypress from '../..' +import type $Cypress from '../..' /** * Fix property reads and writes that could potentially help the AUT to break out of its iframe. diff --git a/packages/driver/tsconfig.json b/packages/driver/tsconfig.json index f6c51d76092c..0bcf2e68b824 100644 --- a/packages/driver/tsconfig.json +++ b/packages/driver/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "./../ts/tsconfig.json", "compilerOptions": { "target": "ES2016", "module": "commonjs", diff --git a/packages/launcher/lib/browsers.ts b/packages/launcher/lib/browsers.ts index 6aa0dc750940..22dae9ec01c5 100644 --- a/packages/launcher/lib/browsers.ts +++ b/packages/launcher/lib/browsers.ts @@ -1,6 +1,6 @@ import { log } from './log' import * as cp from 'child_process' -import { Browser, FoundBrowser } from './types' +import type { Browser, FoundBrowser } from './types' // Chrome started exposing CDP 1.3 in 64 const MIN_CHROME_VERSION = 64 diff --git a/packages/launcher/lib/darwin/index.ts b/packages/launcher/lib/darwin/index.ts index e5f1d0bd65ad..b9420e972aaf 100644 --- a/packages/launcher/lib/darwin/index.ts +++ b/packages/launcher/lib/darwin/index.ts @@ -1,5 +1,5 @@ import { findApp, FindAppParams } from './util' -import { Browser, DetectedBrowser } from '../types' +import type { Browser, DetectedBrowser } from '../types' import * as linuxHelper from '../linux' import { log } from '../log' import { merge } from 'ramda' diff --git a/packages/launcher/lib/darwin/util.ts b/packages/launcher/lib/darwin/util.ts index 4992fb857d82..f9a54233b6f6 100644 --- a/packages/launcher/lib/darwin/util.ts +++ b/packages/launcher/lib/darwin/util.ts @@ -7,7 +7,7 @@ import * as os from 'os' import * as path from 'path' import * as plist from 'plist' import * as semver from 'semver' -import { FoundBrowser } from '../types' +import type { FoundBrowser } from '../types' import * as findSystemNode from '@packages/server/lib/util/find_system_node' /** parses Info.plist file from given application and returns a property */ diff --git a/packages/launcher/lib/detect.ts b/packages/launcher/lib/detect.ts index d489f333e2b5..ad41e0bc955b 100644 --- a/packages/launcher/lib/detect.ts +++ b/packages/launcher/lib/detect.ts @@ -8,7 +8,7 @@ import { needsDarwinWorkaround, darwinDetectionWorkaround } from './darwin/util' import { notDetectedAtPathErr } from './errors' import * as linuxHelper from './linux' import { log } from './log' -import { +import type { Browser, DetectedBrowser, FoundBrowser, diff --git a/packages/launcher/lib/errors.ts b/packages/launcher/lib/errors.ts index e56be0b4675c..bf9e46129097 100644 --- a/packages/launcher/lib/errors.ts +++ b/packages/launcher/lib/errors.ts @@ -1,4 +1,4 @@ -import { NotInstalledError, NotDetectedAtPathError } from './types' +import type { NotInstalledError, NotDetectedAtPathError } from './types' export const notInstalledErr = (name: string, message?: string) => { const err = new Error( diff --git a/packages/launcher/lib/linux/index.ts b/packages/launcher/lib/linux/index.ts index d08778734088..6942ceac5dbd 100644 --- a/packages/launcher/lib/linux/index.ts +++ b/packages/launcher/lib/linux/index.ts @@ -1,6 +1,6 @@ import { log } from '../log' import { partial, trim, tap, prop } from 'ramda' -import { FoundBrowser, Browser, PathData } from '../types' +import type { FoundBrowser, Browser, PathData } from '../types' import { notInstalledErr } from '../errors' import { utils } from '../utils' import os from 'os' diff --git a/packages/launcher/lib/types.ts b/packages/launcher/lib/types.ts index 9b1dc888b079..1ba2f7a43b75 100644 --- a/packages/launcher/lib/types.ts +++ b/packages/launcher/lib/types.ts @@ -1,5 +1,5 @@ -import { ChildProcess } from 'child_process' -import * as Bluebird from 'bluebird' +import type { ChildProcess } from 'child_process' +import type Bluebird from 'bluebird' // TODO: Clean up this file diff --git a/packages/launcher/lib/windows/index.ts b/packages/launcher/lib/windows/index.ts index 3fa8a033e38d..74e0514c9ab9 100644 --- a/packages/launcher/lib/windows/index.ts +++ b/packages/launcher/lib/windows/index.ts @@ -5,7 +5,7 @@ import { tap, trim, prop } from 'ramda' import { get } from 'lodash' import { notInstalledErr } from '../errors' import { log } from '../log' -import { Browser, FoundBrowser, PathData } from '../types' +import type { Browser, FoundBrowser, PathData } from '../types' import { utils } from '../utils' function formFullAppPath (name: string) { diff --git a/packages/net-stubbing/lib/internal-types.ts b/packages/net-stubbing/lib/internal-types.ts index db25aff740c0..b07a85d84da4 100644 --- a/packages/net-stubbing/lib/internal-types.ts +++ b/packages/net-stubbing/lib/internal-types.ts @@ -1,5 +1,5 @@ import * as _ from 'lodash' -import { +import type { RouteMatcherOptionsGeneric, GenericStaticResponse, Subscription, diff --git a/packages/net-stubbing/lib/server/driver-events.ts b/packages/net-stubbing/lib/server/driver-events.ts index db3a98050bbd..e9081f53ce6d 100644 --- a/packages/net-stubbing/lib/server/driver-events.ts +++ b/packages/net-stubbing/lib/server/driver-events.ts @@ -1,6 +1,6 @@ import _ from 'lodash' import Debug from 'debug' -import { +import type { NetStubbingState, GetFixtureFn, BackendRoute, @@ -17,8 +17,8 @@ import { setResponseFromFixture, } from './util' import { InterceptedRequest } from './intercepted-request' -import CyServer from '@packages/server' -import { BackendStaticResponse } from '../internal-types' +import type CyServer from '@packages/server' +import type { BackendStaticResponse } from '../internal-types' const debug = Debug('cypress:net-stubbing:server:driver-events') diff --git a/packages/net-stubbing/lib/server/intercepted-request.ts b/packages/net-stubbing/lib/server/intercepted-request.ts index f9b1b7f6218b..cb79662d52b1 100644 --- a/packages/net-stubbing/lib/server/intercepted-request.ts +++ b/packages/net-stubbing/lib/server/intercepted-request.ts @@ -1,18 +1,18 @@ import _ from 'lodash' -import { IncomingMessage } from 'http' -import { Readable } from 'stream' -import { +import type { IncomingMessage } from 'http' +import type { Readable } from 'stream' +import type { CypressIncomingRequest, CypressOutgoingResponse, } from '@packages/proxy' -import { +import type { NetEvent, Subscription, } from '../types' -import { BackendRoute, NetStubbingState } from './types' +import type { BackendRoute, NetStubbingState } from './types' import { emit, sendStaticResponse } from './util' -import CyServer from '@packages/server' -import { BackendStaticResponse } from '../internal-types' +import type CyServer from '@packages/server' +import type { BackendStaticResponse } from '../internal-types' export class InterceptedRequest { id: string diff --git a/packages/net-stubbing/lib/server/middleware/error.ts b/packages/net-stubbing/lib/server/middleware/error.ts index bc48512223ad..40c6394484e3 100644 --- a/packages/net-stubbing/lib/server/middleware/error.ts +++ b/packages/net-stubbing/lib/server/middleware/error.ts @@ -1,7 +1,7 @@ import Debug from 'debug' -import { ErrorMiddleware } from '@packages/proxy' -import { CyHttpMessages } from '../../types' +import type { ErrorMiddleware } from '@packages/proxy' +import type { CyHttpMessages } from '../../types' import _ from 'lodash' import errors from '@packages/server/lib/errors' diff --git a/packages/net-stubbing/lib/server/middleware/request.ts b/packages/net-stubbing/lib/server/middleware/request.ts index 7c819966e7d4..54e15d752ba9 100644 --- a/packages/net-stubbing/lib/server/middleware/request.ts +++ b/packages/net-stubbing/lib/server/middleware/request.ts @@ -3,7 +3,7 @@ import { concatStream } from '@packages/network' import Debug from 'debug' import url from 'url' -import { +import type { RequestMiddleware, } from '@packages/proxy' import { @@ -19,7 +19,7 @@ import { getBodyEncoding, } from '../util' import { InterceptedRequest } from '../intercepted-request' -import { BackendRoute } from '../types' +import type { BackendRoute } from '../types' const debug = Debug('cypress:net-stubbing:server:intercept-request') diff --git a/packages/net-stubbing/lib/server/middleware/response.ts b/packages/net-stubbing/lib/server/middleware/response.ts index 67e953449b21..1cdd9f5686c0 100644 --- a/packages/net-stubbing/lib/server/middleware/response.ts +++ b/packages/net-stubbing/lib/server/middleware/response.ts @@ -1,10 +1,10 @@ import _ from 'lodash' import { concatStream, httpUtils } from '@packages/network' import Debug from 'debug' -import { Readable } from 'stream' +import type { Readable } from 'stream' import { getEncoding } from 'istextorbinary' -import { +import type { ResponseMiddleware, } from '@packages/proxy' import { diff --git a/packages/net-stubbing/lib/server/route-matching.ts b/packages/net-stubbing/lib/server/route-matching.ts index 8a6fd655e1ca..a6ef43b1db1b 100644 --- a/packages/net-stubbing/lib/server/route-matching.ts +++ b/packages/net-stubbing/lib/server/route-matching.ts @@ -2,9 +2,9 @@ import _ from 'lodash' import minimatch from 'minimatch' import url from 'url' -import { CypressIncomingRequest } from '@packages/proxy' -import { BackendRoute } from './types' -import { RouteMatcherOptions } from '../types' +import type { CypressIncomingRequest } from '@packages/proxy' +import type { BackendRoute } from './types' +import type { RouteMatcherOptions } from '../types' import { getAllStringMatcherFields } from './util' /** diff --git a/packages/net-stubbing/lib/server/state.ts b/packages/net-stubbing/lib/server/state.ts index b29b7cb35be3..49feda725251 100644 --- a/packages/net-stubbing/lib/server/state.ts +++ b/packages/net-stubbing/lib/server/state.ts @@ -1,5 +1,5 @@ import { noop } from 'lodash' -import { NetStubbingState } from './types' +import type { NetStubbingState } from './types' export function state (): NetStubbingState { return { diff --git a/packages/net-stubbing/lib/server/types.ts b/packages/net-stubbing/lib/server/types.ts index 92f39d7ec638..6274d0866589 100644 --- a/packages/net-stubbing/lib/server/types.ts +++ b/packages/net-stubbing/lib/server/types.ts @@ -1,8 +1,8 @@ -import { +import type { RouteMatcherOptions, BackendStaticResponse, } from '../types' -import { +import type { InterceptedRequest, } from './intercepted-request' diff --git a/packages/net-stubbing/lib/server/util.ts b/packages/net-stubbing/lib/server/util.ts index 9b36b058e46b..5a4dd022d6ef 100644 --- a/packages/net-stubbing/lib/server/util.ts +++ b/packages/net-stubbing/lib/server/util.ts @@ -9,18 +9,18 @@ import { BackendStaticResponse, } from '../types' import { Readable, PassThrough } from 'stream' -import CyServer from '@packages/server' +import type CyServer from '@packages/server' import { Socket } from 'net' -import { GetFixtureFn } from './types' +import type { GetFixtureFn } from './types' import ThrottleStream from 'throttle' import MimeTypes from 'mime-types' -import { CypressIncomingRequest } from '@packages/proxy' -import { InterceptedRequest } from './intercepted-request' +import type { CypressIncomingRequest } from '@packages/proxy' +import type { InterceptedRequest } from './intercepted-request' import { caseInsensitiveGet, caseInsensitiveHas } from '../util' // TODO: move this into net-stubbing once cy.route is removed import { parseContentType } from '@packages/server/lib/controllers/xhrs' -import { CyHttpMessages } from '../external-types' +import type { CyHttpMessages } from '../external-types' import { getEncoding } from 'istextorbinary' const debug = Debug('cypress:net-stubbing:server:util') diff --git a/packages/network/lib/allow-destroy.ts b/packages/network/lib/allow-destroy.ts index 967aabdf878c..9dfc186cacc9 100644 --- a/packages/network/lib/allow-destroy.ts +++ b/packages/network/lib/allow-destroy.ts @@ -1,4 +1,4 @@ -import net from 'net' +import type net from 'net' /** * `allowDestroy` adds a `destroy` method to a `net.Server`. `destroy(cb)` diff --git a/packages/network/lib/client-certificates.ts b/packages/network/lib/client-certificates.ts index bee3ec337bdf..b65ebefd0936 100644 --- a/packages/network/lib/client-certificates.ts +++ b/packages/network/lib/client-certificates.ts @@ -1,4 +1,4 @@ -import { Url } from 'url' +import type { Url } from 'url' import debugModule from 'debug' import minimatch from 'minimatch' import Forge from 'node-forge' diff --git a/packages/network/lib/http-utils.ts b/packages/network/lib/http-utils.ts index bf4e18b0450a..fc10003b16a1 100644 --- a/packages/network/lib/http-utils.ts +++ b/packages/network/lib/http-utils.ts @@ -1,5 +1,5 @@ import _ from 'lodash' -import { IncomingMessage } from 'http' +import type { IncomingMessage } from 'http' // https://github.com/cypress-io/cypress/issues/4298 // https://tools.ietf.org/html/rfc7230#section-3.3.3 diff --git a/packages/proxy/lib/http/error-middleware.ts b/packages/proxy/lib/http/error-middleware.ts index dac3f0a3f77e..43de4c39bff1 100644 --- a/packages/proxy/lib/http/error-middleware.ts +++ b/packages/proxy/lib/http/error-middleware.ts @@ -1,8 +1,8 @@ import debugModule from 'debug' -import { HttpMiddleware } from '.' +import type { HttpMiddleware } from '.' +import type { Readable } from 'stream' import { InterceptError } from '@packages/net-stubbing' -import { Readable } from 'stream' -import { Request } from '@cypress/request' +import type { Request } from '@cypress/request' import errors from '@packages/server/lib/errors' const debug = debugModule('cypress:proxy:http:error-middleware') diff --git a/packages/proxy/lib/http/index.ts b/packages/proxy/lib/http/index.ts index 441e02e4d956..f6c84930c34b 100644 --- a/packages/proxy/lib/http/index.ts +++ b/packages/proxy/lib/http/index.ts @@ -1,6 +1,6 @@ import _ from 'lodash' -import CyServer from '@packages/server' -import { +import type CyServer from '@packages/server' +import type { CypressIncomingRequest, CypressOutgoingResponse, BrowserPreRequest, @@ -9,11 +9,11 @@ import Debug from 'debug' import ErrorMiddleware from './error-middleware' import { HttpBuffers } from './util/buffers' import { GetPreRequestCb, PreRequests } from './util/prerequests' -import { IncomingMessage } from 'http' -import { NetStubbingState } from '@packages/net-stubbing' +import type { IncomingMessage } from 'http' +import type { NetStubbingState } from '@packages/net-stubbing' import Bluebird from 'bluebird' -import { Readable } from 'stream' -import { Request, Response } from 'express' +import type { Readable } from 'stream' +import type { Request, Response } from 'express' import RequestMiddleware from './request-middleware' import ResponseMiddleware from './response-middleware' import { DeferredSourceMapCache } from '@packages/rewriter' diff --git a/packages/proxy/lib/http/request-middleware.ts b/packages/proxy/lib/http/request-middleware.ts index e10c8b19fdf2..3d0eba659a84 100644 --- a/packages/proxy/lib/http/request-middleware.ts +++ b/packages/proxy/lib/http/request-middleware.ts @@ -1,9 +1,9 @@ import _ from 'lodash' -import CyServer from '@packages/server' +import type CyServer from '@packages/server' import { blocked, cors } from '@packages/network' import { InterceptRequest } from '@packages/net-stubbing' import debugModule from 'debug' -import { HttpMiddleware } from './' +import type { HttpMiddleware } from './' export type RequestMiddleware = HttpMiddleware<{ outgoingReq: any diff --git a/packages/proxy/lib/http/response-middleware.ts b/packages/proxy/lib/http/response-middleware.ts index 71f6720ad1f1..6cff64815942 100644 --- a/packages/proxy/lib/http/response-middleware.ts +++ b/packages/proxy/lib/http/response-middleware.ts @@ -1,12 +1,12 @@ import _ from 'lodash' import charset from 'charset' -import { CookieOptions } from 'express' +import type { CookieOptions } from 'express' import { cors, concatStream, httpUtils } from '@packages/network' -import { CypressIncomingRequest, CypressOutgoingResponse } from '@packages/proxy' +import type { CypressIncomingRequest, CypressOutgoingResponse } from '@packages/proxy' import debugModule from 'debug' -import { HttpMiddleware } from '.' +import type { HttpMiddleware } from '.' import iconv from 'iconv-lite' -import { IncomingMessage, IncomingHttpHeaders } from 'http' +import type { IncomingMessage, IncomingHttpHeaders } from 'http' import { InterceptResponse } from '@packages/net-stubbing' import { PassThrough, Readable } from 'stream' import * as rewriter from './util/rewriter' diff --git a/packages/proxy/lib/http/util/ast-rewriter.ts b/packages/proxy/lib/http/util/ast-rewriter.ts index 5b5c7752dc8e..9d162adcf234 100644 --- a/packages/proxy/lib/http/util/ast-rewriter.ts +++ b/packages/proxy/lib/http/util/ast-rewriter.ts @@ -2,7 +2,7 @@ import { HtmlJsRewriter, rewriteHtmlJsAsync, rewriteJsAsync } from '@packages/re import duplexify from 'duplexify' import { concatStream } from '@packages/network' import stream from 'stream' -import { SecurityOpts } from './rewriter' +import type { SecurityOpts } from './rewriter' const pumpify = require('pumpify') const utf8Stream = require('utf8-stream') diff --git a/packages/proxy/lib/http/util/buffers.ts b/packages/proxy/lib/http/util/buffers.ts index 6a2dbb54e751..b1ad4b63a6ee 100644 --- a/packages/proxy/lib/http/util/buffers.ts +++ b/packages/proxy/lib/http/util/buffers.ts @@ -1,8 +1,8 @@ import _ from 'lodash' import debugModule from 'debug' import { uri } from '@packages/network' -import { Readable } from 'stream' -import { IncomingMessage } from 'http' +import type { Readable } from 'stream' +import type { IncomingMessage } from 'http' const debug = debugModule('cypress:proxy:http:util:buffers') diff --git a/packages/proxy/lib/http/util/prerequests.ts b/packages/proxy/lib/http/util/prerequests.ts index f710d409ab21..2774cfc2f216 100644 --- a/packages/proxy/lib/http/util/prerequests.ts +++ b/packages/proxy/lib/http/util/prerequests.ts @@ -1,4 +1,4 @@ -import { +import type { CypressIncomingRequest, BrowserPreRequest, } from '@packages/proxy' diff --git a/packages/proxy/lib/network-proxy.ts b/packages/proxy/lib/network-proxy.ts index 84decf291368..01976365feaf 100644 --- a/packages/proxy/lib/network-proxy.ts +++ b/packages/proxy/lib/network-proxy.ts @@ -1,5 +1,5 @@ import { Http, ServerCtx } from './http' -import { BrowserPreRequest } from './types' +import type { BrowserPreRequest } from './types' export class NetworkProxy { http: Http diff --git a/packages/proxy/lib/types.ts b/packages/proxy/lib/types.ts index 80a0416c5cae..0c78c9e86a78 100644 --- a/packages/proxy/lib/types.ts +++ b/packages/proxy/lib/types.ts @@ -1,5 +1,5 @@ -import { Readable } from 'stream' -import { Request, Response } from 'express' +import type { Readable } from 'stream' +import type { Request, Response } from 'express' /** * An incoming request to the Cypress web server. diff --git a/packages/reporter/src/commands/command-model.ts b/packages/reporter/src/commands/command-model.ts index 5b13b90ed9ca..bd877bd18ea9 100644 --- a/packages/reporter/src/commands/command-model.ts +++ b/packages/reporter/src/commands/command-model.ts @@ -3,7 +3,7 @@ import { action, computed, observable } from 'mobx' import Err from '../errors/err-model' import Instrument, { InstrumentProps } from '../instruments/instrument-model' -import { TimeoutID } from '../lib/types' +import type { TimeoutID } from '../lib/types' const LONG_RUNNING_THRESHOLD = 1000 diff --git a/packages/reporter/src/errors/err-model.ts b/packages/reporter/src/errors/err-model.ts index 67c8c97de822..e511a09ddc51 100644 --- a/packages/reporter/src/errors/err-model.ts +++ b/packages/reporter/src/errors/err-model.ts @@ -2,7 +2,7 @@ import _ from 'lodash' import { computed, observable } from 'mobx' -import { FileDetails } from '@packages/ui-components' +import type { FileDetails } from '@packages/ui-components' export interface ParsedStackMessageLine { message: string diff --git a/packages/reporter/tsconfig.json b/packages/reporter/tsconfig.json index ccc63e9c6d84..b7c0ecf944c0 100644 --- a/packages/reporter/tsconfig.json +++ b/packages/reporter/tsconfig.json @@ -5,7 +5,8 @@ "node", "cypress", "cypress-real-events" - ] /* Type declaration files to be included in compilation. */ + ], /* Type declaration files to be included in compilation. */ + "importsNotUsedAsValues": "remove" }, "include": [ "src/*.ts", diff --git a/packages/reporter/webpack.config.ts b/packages/reporter/webpack.config.ts index 504d61eaae72..792019f696d2 100644 --- a/packages/reporter/webpack.config.ts +++ b/packages/reporter/webpack.config.ts @@ -1,9 +1,9 @@ import { getCommonConfig, HtmlWebpackPlugin } from '@packages/web-config/webpack.config.base' import path from 'path' -import webpack from 'webpack' +import type { Configuration } from 'webpack' // @ts-ignore -const config: webpack.Configuration = { +const config: Configuration = { ...getCommonConfig(), entry: { reporter: [path.resolve(__dirname, 'src')], diff --git a/packages/rewriter/lib/async-rewriters.ts b/packages/rewriter/lib/async-rewriters.ts index 1b74385654a9..287dc314af9e 100644 --- a/packages/rewriter/lib/async-rewriters.ts +++ b/packages/rewriter/lib/async-rewriters.ts @@ -1,5 +1,5 @@ import { queueRewriting } from './threads' -import { DeferSourceMapRewriteFn } from './js' +import type { DeferSourceMapRewriteFn } from './js' // these functions are not included in `./js` or `./html` because doing so // would mean that `./threads/worker` would unnecessarily end up loading in the diff --git a/packages/rewriter/lib/html-rules.ts b/packages/rewriter/lib/html-rules.ts index 21481479ebd3..59220f525d40 100644 --- a/packages/rewriter/lib/html-rules.ts +++ b/packages/rewriter/lib/html-rules.ts @@ -1,5 +1,5 @@ import find from 'lodash/find' -import RewritingStream from 'parse5-html-rewriting-stream' +import type RewritingStream from 'parse5-html-rewriting-stream' import * as js from './js' export function install (url: string, rewriter: RewritingStream, deferSourceMapRewrite?: js.DeferSourceMapRewriteFn) { diff --git a/packages/rewriter/lib/html.ts b/packages/rewriter/lib/html.ts index 1a498323cbbf..aa913fc2fdb4 100644 --- a/packages/rewriter/lib/html.ts +++ b/packages/rewriter/lib/html.ts @@ -1,7 +1,7 @@ import RewritingStream from 'parse5-html-rewriting-stream' import * as htmlRules from './html-rules' -import stream from 'stream' -import { DeferSourceMapRewriteFn } from './js' +import type stream from 'stream' +import type { DeferSourceMapRewriteFn } from './js' // the HTML rewriter passes inline JS to the JS rewriter, hence // the lack of basic `rewriteHtml` or `HtmlRewriter` exports here diff --git a/packages/rewriter/lib/js-rules.ts b/packages/rewriter/lib/js-rules.ts index a1d714f96cd4..bdfb278187bf 100644 --- a/packages/rewriter/lib/js-rules.ts +++ b/packages/rewriter/lib/js-rules.ts @@ -3,7 +3,7 @@ import { namedTypes as n, builders as b, } from 'ast-types' -import { ExpressionKind } from 'ast-types/gen/kinds' +import type { ExpressionKind } from 'ast-types/gen/kinds' // use `globalThis` instead of `window`, `self`... to lower chances of scope conflict // users can technically override even this, but it would be very rude diff --git a/packages/rewriter/lib/threads/index.ts b/packages/rewriter/lib/threads/index.ts index c963bf1f09e0..7bada92d5f52 100644 --- a/packages/rewriter/lib/threads/index.ts +++ b/packages/rewriter/lib/threads/index.ts @@ -4,8 +4,8 @@ import Debug from 'debug' import * as path from 'path' import os from 'os' import { MessageChannel, Worker } from 'worker_threads' -import { RewriteRequest, RewriteResponse } from './types' -import { DeferSourceMapRewriteFn } from '../js' +import type { RewriteRequest, RewriteResponse } from './types' +import type { DeferSourceMapRewriteFn } from '../js' const debug = Debug('cypress:rewriter:threads') diff --git a/packages/rewriter/lib/threads/types.ts b/packages/rewriter/lib/threads/types.ts index 5cad52cc4d81..21b382f313f1 100644 --- a/packages/rewriter/lib/threads/types.ts +++ b/packages/rewriter/lib/threads/types.ts @@ -1,4 +1,4 @@ -import { MessagePort } from 'worker_threads' +import type { MessagePort } from 'worker_threads' export type RewriteRequest = { /** diff --git a/packages/rewriter/lib/threads/worker.ts b/packages/rewriter/lib/threads/worker.ts index dd4de569863d..d1133d3c07d3 100644 --- a/packages/rewriter/lib/threads/worker.ts +++ b/packages/rewriter/lib/threads/worker.ts @@ -10,7 +10,7 @@ if (isMainThread) { import { rewriteJs, rewriteJsSourceMap } from '../js' import { rewriteHtmlJs } from '../html' -import { RewriteRequest, RewriteResponse } from './types' +import type { RewriteRequest, RewriteResponse } from './types' parentPort!.postMessage(true) diff --git a/packages/runner-ct/webpack.config.ts b/packages/runner-ct/webpack.config.ts index e5ef5a8f351f..25587a647a41 100644 --- a/packages/runner-ct/webpack.config.ts +++ b/packages/runner-ct/webpack.config.ts @@ -2,7 +2,7 @@ process.env.NO_LIVERELOAD = '1' import _ from 'lodash' import path from 'path' -import webpack from 'webpack' +import type webpack from 'webpack' import { getCommonConfig, HtmlWebpackPlugin } from '@packages/web-config/webpack.config.base' const commonConfig = getCommonConfig() diff --git a/packages/server-ct/src/routes-ct.ts b/packages/server-ct/src/routes-ct.ts index beea816ef1ee..51b2991fb2d4 100644 --- a/packages/server-ct/src/routes-ct.ts +++ b/packages/server-ct/src/routes-ct.ts @@ -1,14 +1,14 @@ import Debug from 'debug' -import { ErrorRequestHandler, Express } from 'express' -import httpProxy from 'http-proxy' +import type { ErrorRequestHandler, Express } from 'express' +import type httpProxy from 'http-proxy' import send from 'send' -import { NetworkProxy } from '@packages/proxy' +import type { NetworkProxy } from '@packages/proxy' import { handle, serve, serveChunk } from './runner-ct' import xhrs from '@packages/server/lib/controllers/xhrs' -import { SpecsStore } from '@packages/server/lib/specs-store' -import { Cfg } from '@packages/server/lib/project-base' +import type { SpecsStore } from '@packages/server/lib/specs-store' +import type { Cfg } from '@packages/server/lib/project-base' import { getPathToDist } from '@packages/resolve-dist' -import { Browser } from '@packages/server/lib/browsers/types' +import type { Browser } from '@packages/server/lib/browsers/types' const debug = Debug('cypress:server:routes') diff --git a/packages/server-ct/src/runner-ct.ts b/packages/server-ct/src/runner-ct.ts index 48ee08d19a2d..0d18ead0d564 100644 --- a/packages/server-ct/src/runner-ct.ts +++ b/packages/server-ct/src/runner-ct.ts @@ -1,10 +1,10 @@ import Debug from 'debug' import _ from 'lodash' import send from 'send' -import { SpecsStore } from '@packages/server/lib/specs-store' +import type { SpecsStore } from '@packages/server/lib/specs-store' import { getPathToIndex, getPathToDist } from '@packages/resolve-dist' -import { Cfg } from '@packages/server/lib/project-base' -import { Browser } from '@packages/server/lib/browsers/types' +import type { Cfg } from '@packages/server/lib/project-base' +import type { Browser } from '@packages/server/lib/browsers/types' interface ServeOptions { config: Cfg diff --git a/packages/server-ct/src/server-ct.ts b/packages/server-ct/src/server-ct.ts index 91de75bcbd09..b02eb49202c7 100644 --- a/packages/server-ct/src/server-ct.ts +++ b/packages/server-ct/src/server-ct.ts @@ -2,8 +2,8 @@ import Bluebird from 'bluebird' import httpsProxy from '@packages/https-proxy' import { OpenServerOptions, ServerBase } from '@packages/server/lib/server-base' import appData from '@packages/server/lib/util/app_data' -import { SocketCt } from './socket-ct' -import { Cfg } from '@packages/server/lib/project-base' +import type { SocketCt } from './socket-ct' +import type { Cfg } from '@packages/server/lib/project-base' type WarningErr = Record diff --git a/packages/server-ct/src/socket-ct.ts b/packages/server-ct/src/socket-ct.ts index b21406ab631d..26a8e343d884 100644 --- a/packages/server-ct/src/socket-ct.ts +++ b/packages/server-ct/src/socket-ct.ts @@ -1,8 +1,8 @@ import Debug from 'debug' -import * as socketIo from '@packages/socket' +import type * as socketIo from '@packages/socket' import devServer from '@packages/server/lib/plugins/dev-server' import { SocketBase } from '@packages/server/lib/socket-base' -import { DestroyableHttpServer } from '@packages/server/lib/util/server_destroy' +import type { DestroyableHttpServer } from '@packages/server/lib/util/server_destroy' const debug = Debug('cypress:server-ct:socket-ct') diff --git a/packages/server/lib/automation/automation.ts b/packages/server/lib/automation/automation.ts index 6a35eee80c15..2bb0059a0dae 100644 --- a/packages/server/lib/automation/automation.ts +++ b/packages/server/lib/automation/automation.ts @@ -2,7 +2,7 @@ import Bluebird from 'bluebird' import { v4 as uuidv4 } from 'uuid' import { Cookies } from './cookies' import { Screenshot } from './screenshot' -import { BrowserPreRequest } from '@packages/proxy' +import type { BrowserPreRequest } from '@packages/proxy' type NullableMiddlewareHook = (() => void) | null diff --git a/packages/server/lib/browsers/cdp_automation.ts b/packages/server/lib/browsers/cdp_automation.ts index a8e5dcef4215..4271e8d6e033 100644 --- a/packages/server/lib/browsers/cdp_automation.ts +++ b/packages/server/lib/browsers/cdp_automation.ts @@ -2,11 +2,11 @@ import _ from 'lodash' import Bluebird from 'bluebird' -import cdp from 'devtools-protocol' +import type { Protocol } from 'devtools-protocol' import { cors } from '@packages/network' import debugModule from 'debug' -import { Automation } from '../automation' -import { ResourceType, BrowserPreRequest, BrowserResponseReceived } from '@packages/proxy' +import type { Automation } from '../automation' +import type { ResourceType, BrowserPreRequest, BrowserResponseReceived } from '@packages/proxy' const debugVerbose = debugModule('cypress-verbose:server:browsers:cdp_automation') @@ -19,12 +19,12 @@ export type CyCookie = Pick { +const normalizeGetCookieProps = (cookie: Protocol.Network.Cookie): CyCookie => { if (cookie.expires === -1) { // @ts-ignore delete cookie.expires @@ -101,16 +101,16 @@ const normalizeGetCookieProps = (cookie: cdp.Network.Cookie): CyCookie => { return cookie } -const normalizeGetCookies = (cookies: cdp.Network.Cookie[]) => { +const normalizeGetCookies = (cookies: Protocol.Network.Cookie[]) => { return _.map(cookies, normalizeGetCookieProps) } -const normalizeSetCookieProps = (cookie: CyCookie): cdp.Network.SetCookieRequest => { +const normalizeSetCookieProps = (cookie: CyCookie): Protocol.Network.SetCookieRequest => { // this logic forms a SetCookie request that will be received by Chrome // see MakeCookieFromProtocolValues for information on how this cookie data will be parsed // @see https://cs.chromium.org/chromium/src/content/browser/devtools/protocol/network_handler.cc?l=246&rcl=786a9194459684dc7a6fded9cabfc0c9b9b37174 - const setCookieRequest: cdp.Network.SetCookieRequest = _({ + const setCookieRequest: Protocol.Network.SetCookieRequest = _({ domain: cookie.domain, path: cookie.path, secure: cookie.secure, @@ -183,7 +183,7 @@ export class CdpAutomation { }) } - private onNetworkRequestWillBeSent = (params: cdp.Network.RequestWillBeSentEvent) => { + private onNetworkRequestWillBeSent = (params: Protocol.Network.RequestWillBeSentEvent) => { debugVerbose('received networkRequestWillBeSent %o', params) let url = params.request.url @@ -204,7 +204,7 @@ export class CdpAutomation { this.automation.onBrowserPreRequest?.(browserPreRequest) } - private onResponseReceived = (params: cdp.Network.ResponseReceivedEvent) => { + private onResponseReceived = (params: Protocol.Network.ResponseReceivedEvent) => { const browserResponseReceived: BrowserResponseReceived = { requestId: params.requestId, status: params.response.status, @@ -216,7 +216,7 @@ export class CdpAutomation { private getAllCookies = (filter: CyCookieFilter) => { return this.sendDebuggerCommandFn('Network.getAllCookies') - .then((result: cdp.Network.GetAllCookiesResponse) => { + .then((result: Protocol.Network.GetAllCookiesResponse) => { return normalizeGetCookies(result.cookies) .filter((cookie: CyCookie) => { const matches = _cookieMatches(cookie, filter) @@ -232,7 +232,7 @@ export class CdpAutomation { return this.sendDebuggerCommandFn('Network.getCookies', { urls: [url], }) - .then((result: cdp.Network.GetCookiesResponse) => { + .then((result: Protocol.Network.GetCookiesResponse) => { return normalizeGetCookies(result.cookies) .filter((cookie) => { return !(url.startsWith('http:') && cookie.secure) @@ -263,7 +263,7 @@ export class CdpAutomation { setCookie = normalizeSetCookieProps(data) return this.sendDebuggerCommandFn('Network.setCookie', setCookie) - .then((result: cdp.Network.SetCookieResponse) => { + .then((result: Protocol.Network.SetCookieResponse) => { if (!result.success) { // i wish CDP provided some more detail here, but this is really it in v1.3 // @see https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setCookie diff --git a/packages/server/lib/browsers/chrome.ts b/packages/server/lib/browsers/chrome.ts index dbf86c03b25c..955119d02e16 100644 --- a/packages/server/lib/browsers/chrome.ts +++ b/packages/server/lib/browsers/chrome.ts @@ -15,7 +15,7 @@ import { CdpAutomation, screencastOpts } from './cdp_automation' import * as CriClient from './cri-client' import * as protocol from './protocol' import utils from './utils' -import { Browser } from './types' +import type { Browser } from './types' // TODO: this is defined in `cypress-npm-api` but there is currently no way to get there type CypressConfiguration = any diff --git a/packages/server/lib/browsers/firefox.ts b/packages/server/lib/browsers/firefox.ts index 95a4358fefd2..97e5fe2db924 100644 --- a/packages/server/lib/browsers/firefox.ts +++ b/packages/server/lib/browsers/firefox.ts @@ -10,7 +10,7 @@ import FirefoxProfile from 'firefox-profile' import firefoxUtil from './firefox-util' import utils from './utils' import * as launcherDebug from '@packages/launcher/lib/log' -import { Browser, BrowserInstance } from './types' +import type { Browser, BrowserInstance } from './types' import { EventEmitter } from 'events' import os from 'os' import treeKill from 'tree-kill' diff --git a/packages/server/lib/browsers/protocol.ts b/packages/server/lib/browsers/protocol.ts index 850b0b330fb0..bf6054ecea4c 100644 --- a/packages/server/lib/browsers/protocol.ts +++ b/packages/server/lib/browsers/protocol.ts @@ -4,7 +4,7 @@ import { connect } from '@packages/network' import Bluebird from 'bluebird' import la from 'lazy-ass' import Debug from 'debug' -import { Socket } from 'net' +import type { Socket } from 'net' import utils from './utils' const errors = require('../errors') const is = require('check-more-types') diff --git a/packages/server/lib/browsers/types.ts b/packages/server/lib/browsers/types.ts index fdfdd6498cbd..92703be5ff60 100644 --- a/packages/server/lib/browsers/types.ts +++ b/packages/server/lib/browsers/types.ts @@ -1,5 +1,5 @@ -import { FoundBrowser } from '@packages/launcher' -import { EventEmitter } from 'events' +import type { FoundBrowser } from '@packages/launcher' +import type { EventEmitter } from 'events' export type Browser = FoundBrowser & { majorVersion: number diff --git a/packages/server/lib/browsers/utils.ts b/packages/server/lib/browsers/utils.ts index 90eb0044ea61..0aef5c5f0c48 100644 --- a/packages/server/lib/browsers/utils.ts +++ b/packages/server/lib/browsers/utils.ts @@ -1,5 +1,5 @@ import _ from 'lodash' -import { FoundBrowser } from '@packages/launcher' +import type { FoundBrowser } from '@packages/launcher' // @ts-ignore import errors from '../errors' // @ts-ignore diff --git a/packages/server/lib/routes.ts b/packages/server/lib/routes.ts index 212a30a47aa8..950ac33427c1 100644 --- a/packages/server/lib/routes.ts +++ b/packages/server/lib/routes.ts @@ -3,7 +3,7 @@ import la from 'lazy-ass' import check from 'check-more-types' import Debug from 'debug' -import { InitializeRoutes } from '@packages/server-ct/src/routes-ct' +import type { InitializeRoutes } from '@packages/server-ct/src/routes-ct' import AppData from './util/app_data' import CacheBuster from './util/cache_buster' import specController from './controllers/spec' diff --git a/packages/server/lib/server-base.ts b/packages/server/lib/server-base.ts index 2f56a3aaa4e4..2c9481f94537 100644 --- a/packages/server/lib/server-base.ts +++ b/packages/server/lib/server-base.ts @@ -7,28 +7,28 @@ import express, { Express } from 'express' import http from 'http' import httpProxy from 'http-proxy' import _ from 'lodash' -import { AddressInfo } from 'net' +import type { AddressInfo } from 'net' import url from 'url' import la from 'lazy-ass' -import httpsProxy from '@packages/https-proxy' +import type httpsProxy from '@packages/https-proxy' import { netStubbingState, NetStubbingState } from '@packages/net-stubbing' import { agent, clientCertificates, cors, httpUtils, uri } from '@packages/network' import { NetworkProxy, BrowserPreRequest } from '@packages/proxy' -import { SocketCt } from '@packages/server-ct' +import type { SocketCt } from '@packages/server-ct' import errors from './errors' import logger from './logger' import Request from './request' -import { SocketE2E } from './socket-e2e' +import type { SocketE2E } from './socket-e2e' import templateEngine from './template_engine' import { ensureProp } from './util/class-helpers' import origin from './util/origin' import { allowDestroy, DestroyableHttpServer } from './util/server_destroy' import { SocketAllowed } from './util/socket_allowed' import { createInitialWorkers } from '@packages/rewriter' -import { SpecsStore } from './specs-store' -import { InitializeRoutes } from '../../server-ct/src/routes-ct' -import { Cfg } from './project-base' -import { Browser } from '@packages/server/lib/browsers/types' +import type { SpecsStore } from './specs-store' +import type { InitializeRoutes } from '../../server-ct/src/routes-ct' +import type { Cfg } from './project-base' +import type { Browser } from '@packages/server/lib/browsers/types' const ALLOWED_PROXY_BYPASS_URLS = [ '/', diff --git a/packages/server/lib/server-e2e.ts b/packages/server/lib/server-e2e.ts index 0d5ba78c7a90..531962cedc91 100644 --- a/packages/server/lib/server-e2e.ts +++ b/packages/server/lib/server-e2e.ts @@ -10,12 +10,12 @@ import { concatStream, cors } from '@packages/network' import errors from './errors' import fileServer from './file_server' import { OpenServerOptions, ServerBase } from './server-base' -import { SocketE2E } from './socket-e2e' +import type { SocketE2E } from './socket-e2e' import appData from './util/app_data' import * as ensureUrl from './util/ensure-url' import headersUtil from './util/headers' import statusCode from './util/status_code' -import { Cfg } from './project-base' +import type { Cfg } from './project-base' type WarningErr = Record diff --git a/packages/server/lib/session.ts b/packages/server/lib/session.ts index 7e873fb3cda3..1b1174cf74cd 100644 --- a/packages/server/lib/session.ts +++ b/packages/server/lib/session.ts @@ -1,4 +1,4 @@ -import { CyCookie } from './browsers/cdp_automation' +import type { CyCookie } from './browsers/cdp_automation' interface SessionData { cookies: CyCookie[] diff --git a/packages/server/lib/socket-base.ts b/packages/server/lib/socket-base.ts index 77c1e174f77e..87e0556e5566 100644 --- a/packages/server/lib/socket-base.ts +++ b/packages/server/lib/socket-base.ts @@ -13,7 +13,7 @@ import { ensureProp } from './util/class-helpers' import { getUserEditor, setUserEditor } from './util/editors' import { openFile } from './util/file-opener' import open from './util/open' -import { DestroyableHttpServer } from './util/server_destroy' +import type { DestroyableHttpServer } from './util/server_destroy' import * as session from './session' type StartListeningCallbacks = { diff --git a/packages/server/lib/socket-e2e.ts b/packages/server/lib/socket-e2e.ts index cc404f3cc29e..2d633831a4c5 100644 --- a/packages/server/lib/socket-e2e.ts +++ b/packages/server/lib/socket-e2e.ts @@ -3,7 +3,7 @@ import path from 'path' import preprocessor from './plugins/preprocessor' import { SocketBase } from './socket-base' import { fs } from './util/fs' -import { DestroyableHttpServer } from './util/server_destroy' +import type { DestroyableHttpServer } from './util/server_destroy' import * as studio from './studio' const debug = Debug('cypress:server:socket-e2e') diff --git a/packages/server/lib/specs-store.ts b/packages/server/lib/specs-store.ts index fe1d1508128e..90a3ff2e5a20 100644 --- a/packages/server/lib/specs-store.ts +++ b/packages/server/lib/specs-store.ts @@ -1,4 +1,4 @@ -import Bluebird from 'bluebird' +import type Bluebird from 'bluebird' import chokidar, { FSWatcher } from 'chokidar' import _ from 'lodash' import { findSpecsOfType } from './util/specs' diff --git a/packages/server/lib/util/passthru_stream.ts b/packages/server/lib/util/passthru_stream.ts index 31b3e8e0b962..c6c4bc946f30 100644 --- a/packages/server/lib/util/passthru_stream.ts +++ b/packages/server/lib/util/passthru_stream.ts @@ -1,4 +1,4 @@ -import { Transform } from 'stream' +import type { Transform } from 'stream' const through = require('through') diff --git a/packages/server/lib/util/server_destroy.ts b/packages/server/lib/util/server_destroy.ts index 2a030670a5cf..b8086466c6e1 100644 --- a/packages/server/lib/util/server_destroy.ts +++ b/packages/server/lib/util/server_destroy.ts @@ -1,5 +1,5 @@ import Bluebird from 'bluebird' -import http from 'http' +import type http from 'http' import * as network from '@packages/network' export interface DestroyableHttpServer extends http.Server { diff --git a/packages/server/lib/util/socket_allowed.ts b/packages/server/lib/util/socket_allowed.ts index 46ed8a32a386..02959a6522d2 100644 --- a/packages/server/lib/util/socket_allowed.ts +++ b/packages/server/lib/util/socket_allowed.ts @@ -1,7 +1,7 @@ import _ from 'lodash' import Debug from 'debug' -import net from 'net' -import { Request } from 'express' +import type net from 'net' +import type { Request } from 'express' const debug = Debug('cypress:server:util:socket_allowed') diff --git a/packages/socket/lib/socket.ts b/packages/socket/lib/socket.ts index eae6874cec65..e93099df99a9 100644 --- a/packages/socket/lib/socket.ts +++ b/packages/socket/lib/socket.ts @@ -1,5 +1,5 @@ import fs from 'fs' -import http from 'http' +import type http from 'http' import server, { Server as SocketIOBaseServer, ServerOptions } from 'socket.io' import { client } from './browser' diff --git a/packages/ts/tsconfig.json b/packages/ts/tsconfig.json index ac3cde25e63f..045ac1bf0350 100644 --- a/packages/ts/tsconfig.json +++ b/packages/ts/tsconfig.json @@ -50,5 +50,6 @@ /* Experimental Options */ "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + "importsNotUsedAsValues": "error" } }