diff --git a/packages/wrangler/src/api/worker.ts b/packages/wrangler/src/api/worker.ts index 382cad8487dd..65b27bbd203c 100644 --- a/packages/wrangler/src/api/worker.ts +++ b/packages/wrangler/src/api/worker.ts @@ -112,7 +112,7 @@ export interface CfWorkerInit { /** * The name of the worker. */ - name: string | void; + name: string | undefined; /** * The entrypoint module. */ @@ -120,7 +120,7 @@ export interface CfWorkerInit { /** * The list of additional modules. */ - modules: void | CfModule[]; + modules: undefined | CfModule[]; /** * All the bindings */ @@ -130,10 +130,10 @@ export interface CfWorkerInit { vars?: CfVars; services?: CfService[]; }; - migrations: void | CfDurableObjectMigrations; - compatibility_date: string | void; - compatibility_flags: void | string[]; - usage_model: void | "bundled" | "unbound"; + migrations: undefined | CfDurableObjectMigrations; + compatibility_date: string | undefined; + compatibility_flags: undefined | string[]; + usage_model: undefined | "bundled" | "unbound"; } /** diff --git a/packages/wrangler/src/config.ts b/packages/wrangler/src/config.ts index 6992fba7c74a..794b54b9e9af 100644 --- a/packages/wrangler/src/config.ts +++ b/packages/wrangler/src/config.ts @@ -127,5 +127,5 @@ export type Config = { usage_model?: UsageModel; // inherited // top level build?: Build; - env?: { [envName: string]: void | Env }; + env?: { [envName: string]: undefined | Env }; }; diff --git a/packages/wrangler/src/dev.tsx b/packages/wrangler/src/dev.tsx index bdbe64baf768..f04fafb0663f 100644 --- a/packages/wrangler/src/dev.tsx +++ b/packages/wrangler/src/dev.tsx @@ -26,23 +26,23 @@ import { usePreviewServer } from "./proxy"; import { execa } from "execa"; import { watch } from "chokidar"; -type CfScriptFormat = void | "modules" | "service-worker"; +type CfScriptFormat = undefined | "modules" | "service-worker"; export type DevProps = { name?: string; entry: string; port?: number; format: CfScriptFormat; - accountId: void | string; + accountId: undefined | string; initialMode: "local" | "remote"; - jsxFactory: void | string; - jsxFragment: void | string; + jsxFactory: undefined | string; + jsxFragment: undefined | string; bindings: CfWorkerInit["bindings"]; public: undefined | string; - site: void | string; - compatibilityDate: void | string; - compatibilityFlags: void | string[]; - usageModel: void | "bundled" | "unbound"; + site: undefined | string; + compatibilityDate: undefined | string; + compatibilityFlags: undefined | string[]; + usageModel: undefined | "bundled" | "unbound"; buildCommand: { command?: undefined | string; cwd?: undefined | string; @@ -130,18 +130,18 @@ function Dev(props: DevProps): JSX.Element { } function Remote(props: { - name: void | string; - bundle: EsbuildBundle | void; + name: undefined | string; + bundle: EsbuildBundle | undefined; format: CfScriptFormat; public: undefined | string; - site: void | string; + site: undefined | string; port: number; - accountId: void | string; - apiToken: void | string; + accountId: undefined | string; + apiToken: undefined | string; bindings: CfWorkerInit["bindings"]; - compatibilityDate: string | void; - compatibilityFlags: void | string[]; - usageModel: void | "bundled" | "unbound"; + compatibilityDate: string | undefined; + compatibilityFlags: undefined | string[]; + usageModel: undefined | "bundled" | "unbound"; }) { assert(props.accountId, "accountId is required"); assert(props.apiToken, "apiToken is required"); @@ -174,12 +174,12 @@ function Remote(props: { return null; } function Local(props: { - name: void | string; - bundle: EsbuildBundle | void; + name: undefined | string; + bundle: EsbuildBundle | undefined; format: CfScriptFormat; bindings: CfWorkerInit["bindings"]; - public: void | string; - site: void | string; + public: undefined | string; + site: undefined | string; port: number; }) { const { inspectorUrl } = useLocalWorker({ @@ -194,8 +194,8 @@ function Local(props: { } function useLocalWorker(props: { - name: void | string; - bundle: EsbuildBundle | void; + name: undefined | string; + bundle: EsbuildBundle | undefined; format: CfScriptFormat; bindings: CfWorkerInit["bindings"]; port: number; @@ -320,7 +320,7 @@ function useLocalWorker(props: { return { inspectorUrl }; } -function useTmpDir(): string | void { +function useTmpDir(): string | undefined { const [directory, setDirectory] = useState(); const handleError = useErrorHandler(); useEffect(() => { @@ -358,8 +358,8 @@ function useCustomBuild( cwd?: undefined | string; watch_dir?: undefined | string; } -): void | string { - const [entry, setEntry] = useState( +): undefined | string { + const [entry, setEntry] = useState( // if there's no build command, just return the expected entry props.command ? null : expectedEntry ); @@ -430,12 +430,12 @@ type EsbuildBundle = { }; function useEsbuild(props: { - entry: void | string; - destination: string | void; - staticRoot: void | string; - jsxFactory: string | void; - jsxFragment: string | void; -}): EsbuildBundle | void { + entry: undefined | string; + destination: string | undefined; + staticRoot: undefined | string; + jsxFactory: string | undefined; + jsxFragment: string | undefined; +}): EsbuildBundle | undefined { const { entry, destination, staticRoot, jsxFactory, jsxFragment } = props; const [bundle, setBundle] = useState(); useEffect(() => { @@ -502,18 +502,18 @@ function useEsbuild(props: { } function useWorker(props: { - name: void | string; - bundle: EsbuildBundle | void; + name: undefined | string; + bundle: EsbuildBundle | undefined; format: CfScriptFormat; modules: CfModule[]; accountId: string; apiToken: string; bindings: CfWorkerInit["bindings"]; - sitesFolder: void | string; + sitesFolder: undefined | string; port: number; - compatibilityDate: string | void; - compatibilityFlags: string[] | void; - usageModel: void | "bundled" | "unbound"; + compatibilityDate: string | undefined; + compatibilityFlags: string[] | undefined; + usageModel: undefined | "bundled" | "unbound"; }): CfPreviewToken | undefined { const { name, @@ -637,7 +637,7 @@ const SLEEP_DURATION = 2000; // really need a first class api for this const hostNameRegex = /userHostname="(.*)"/g; async function findTunnelHostname() { - let hostName: string; + let hostName: string | undefined; while (!hostName) { try { const resp = await fetch("http://localhost:8789/metrics"); diff --git a/packages/wrangler/src/publish.ts b/packages/wrangler/src/publish.ts index 128a497ecbaa..cbbc9238518e 100644 --- a/packages/wrangler/src/publish.ts +++ b/packages/wrangler/src/publish.ts @@ -11,7 +11,7 @@ import type { Config } from "./config"; import makeModuleCollector from "./module-collection"; import { syncAssets } from "./sites"; -type CfScriptFormat = void | "modules" | "service-worker"; +type CfScriptFormat = undefined | "modules" | "service-worker"; type Props = { config: Config; @@ -26,8 +26,8 @@ type Props = { triggers?: (string | number)[]; routes?: (string | number)[]; legacyEnv?: boolean; - jsxFactory: void | string; - jsxFragment: void | string; + jsxFactory: undefined | string; + jsxFragment: undefined | string; }; function sleep(ms: number) {