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

[Miniflare 3] Bump to TypeScript 5 and fix bundled TypeScript output #635

Merged
merged 3 commits into from
Jul 21, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
326 changes: 180 additions & 146 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"devDependencies": {
"@ava/typescript": "^4.0.0",
"@microsoft/api-extractor": "^7.33.6",
"@microsoft/api-extractor": "^7.36.3",
"@types/node": "^18.11.9",
"@types/rimraf": "^3.0.2",
"@types/which": "^2.0.1",
Expand All @@ -51,7 +51,7 @@
"patch-package": "^6.4.7",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"typescript": "^4.8.4",
"typescript": "~5.0.4",
"which": "^2.0.2"
},
"engines": {
Expand Down
1 change: 0 additions & 1 deletion packages/miniflare/src/plugins/kv/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ export async function sitesGatewayGet(
typeof e === "object" &&
e !== null &&
"code" in e &&
// @ts-expect-error `e.code` should be `unknown`, fixed in TypeScript 4.9
e.code === "ENOENT"
) {
return;
Expand Down
2 changes: 0 additions & 2 deletions packages/miniflare/src/plugins/queues/gateway.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import assert from "assert";
import crypto from "crypto";
import v8 from "v8";
// @ts-expect-error "devalue" is ESM-only, but we're bundling for CommonJS here.
// That doesn't matter to `esbuild`, which will apply format conversion.
import { stringify } from "devalue";
import { Colorize, bold, green, grey, red, reset, yellow } from "kleur/colors";
import { z } from "zod";
Expand Down
2 changes: 0 additions & 2 deletions packages/miniflare/src/plugins/queues/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-expect-error "devalue" is ESM-only, but we're bundling for CommonJS here.
// That doesn't matter to `esbuild`, which will apply format conversion.
import { stringify } from "devalue";
import semiver from "semiver";
import { z } from "zod";
Expand Down
2 changes: 0 additions & 2 deletions packages/miniflare/src/plugins/queues/router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-expect-error "devalue" is ESM-only, but we're bundling for CommonJS here.
// That doesn't matter to `esbuild`, which will apply format conversion.
import { parse } from "devalue";
import { z } from "zod";
import { Headers, Response } from "../../http";
Expand Down
20 changes: 1 addition & 19 deletions packages/miniflare/src/plugins/r2/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
NoSuchUpload,
PreconditionFailed,
} from "./errors";
import { R2Object, R2ObjectBody } from "./r2Object";
import { R2Object, R2ObjectBody, R2Objects } from "./r2Object";
import {
MultipartPartRow,
MultipartUploadRow,
Expand Down Expand Up @@ -111,24 +111,6 @@ class DigestingStream<
}
}

export interface R2Objects {
// An array of objects matching the list request.
objects: R2Object[];
// If true, indicates there are more results to be retrieved for the current
// list request.
truncated: boolean;
// A token that can be passed to future list calls to resume listing from that
// point.
// Only present if truncated is true.
cursor?: string;
// If a delimiter has been specified, contains all prefixes between the
// specified prefix and the next occurrence of the delimiter. For example, if
// no prefix is provided and the delimiter is "/", "foo/bar/baz" would return
// "foo" as a delimited prefix. If "foo/" was passed as a prefix with the same
// structure and delimiter, "foo/bar" would be returned as a delimited prefix.
delimitedPrefixes: string[];
}

const validate = new Validator();

function generateVersion() {
Expand Down
19 changes: 18 additions & 1 deletion packages/miniflare/src/plugins/r2/r2Object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Blob } from "buffer";
import { ReadableStream, TransformStream } from "stream/web";
import type { R2StringChecksums } from "@cloudflare/workers-types/experimental";
import { HEX_REGEXP } from "../../shared";
import { R2Objects } from "./gateway";
import { ObjectRow, R2HeadResponse, R2HttpFields, R2Range } from "./schemas";

export interface EncodedMetadata {
Expand Down Expand Up @@ -101,3 +100,21 @@ export class R2ObjectBody extends R2Object {
};
}
}

export interface R2Objects {
// An array of objects matching the list request.
objects: R2Object[];
// If true, indicates there are more results to be retrieved for the current
// list request.
truncated: boolean;
// A token that can be passed to future list calls to resume listing from that
// point.
// Only present if truncated is true.
cursor?: string;
// If a delimiter has been specified, contains all prefixes between the
// specified prefix and the next occurrence of the delimiter. For example, if
// no prefix is provided and the delimiter is "/", "foo/bar/baz" would return
// "foo" as a delimited prefix. If "foo/" was passed as a prefix with the same
// structure and delimiter, "foo/bar" would be returned as a delimited prefix.
delimitedPrefixes: string[];
}
4 changes: 2 additions & 2 deletions packages/miniflare/src/plugins/r2/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
decodePersist,
} from "../shared";
import { InternalError, InvalidMetadata } from "./errors";
import { R2Gateway, R2Objects } from "./gateway";
import { EncodedMetadata, R2Object, R2ObjectBody } from "./r2Object";
import { R2Gateway } from "./gateway";
import { EncodedMetadata, R2Object, R2ObjectBody, R2Objects } from "./r2Object";
import { R2BindingRequestSchema } from "./schemas";

async function decodeMetadata(req: Request) {
Expand Down
2 changes: 0 additions & 2 deletions packages/miniflare/src/storage/blob/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export class FileBlobStore implements BlobStore {
typeof e === "object" &&
e !== null &&
"code" in e &&
// @ts-expect-error `e.code` should be `unknown`, fixed in TypeScript 4.9
e.code === "ENOENT"
) {
return null;
Expand Down Expand Up @@ -181,7 +180,6 @@ export class FileBlobStore implements BlobStore {
typeof e === "object" &&
e !== null &&
"code" in e &&
// @ts-expect-error `e.code` should be `unknown`, fixed in TypeScript 4.9
e.code === "ENOENT"
) {
return;
Expand Down
4 changes: 0 additions & 4 deletions packages/miniflare/src/workers/core/entry.worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// @ts-expect-error "devalue" is ESM-only, so TypeScript requires us to use the
// `*.mts` extension, or set `"type": "module"` in our `package.json`. We can't
// do the first as ambient types from `@cloudflare/workers-types` don't seem to
// work, and the second would affect all consumers of `miniflare`.
import { unflatten } from "devalue";
import { CoreBindings, CoreHeaders, LogLevel } from "./constants";
import { structuredSerializableRevivers } from "./devalue";
Expand Down
2 changes: 1 addition & 1 deletion packages/miniflare/src/workers/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "esnext",
"lib": ["esnext"],
"strict": true,
"moduleResolution": "node16",
"moduleResolution": "bundler",
"isolatedModules": true,
"noEmit": true,
"types": ["@cloudflare/workers-types/experimental"]
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "esnext",
"lib": ["esnext"],
"strict": true,
"moduleResolution": "node16",
"moduleResolution": "bundler",
"esModuleInterop": true,
"isolatedModules": true,
"experimentalDecorators": true,
Expand Down