From af35bb8a051b71fce8f4d80e02ce3ac6347a307d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 7 May 2025 16:37:30 +0000 Subject: [PATCH 1/3] Fixes to support building under TypeScript 5.9 --- packages/effect/test/Match.test.ts | 4 ++-- packages/experimental/src/EventJournal.ts | 6 +++--- packages/experimental/src/EventLogEncryption.ts | 12 ++++++------ packages/platform-browser/src/internal/httpClient.ts | 4 ++-- .../src/internal/httpIncomingMessage.ts | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/effect/test/Match.test.ts b/packages/effect/test/Match.test.ts index e90730f5369..85d0565899f 100644 --- a/packages/effect/test/Match.test.ts +++ b/packages/effect/test/Match.test.ts @@ -578,11 +578,11 @@ describe("Match", () => { const match = pipe( M.type(), M.when(M.instanceOf(Uint8Array), (_) => { - assertType()(_) satisfies true + assertType>()(_) satisfies true return "uint8" }), M.when(M.instanceOf(Uint16Array), (_) => { - assertType()(_) satisfies true + assertType>()(_) satisfies true return "uint16" }), M.orElse((_) => { diff --git a/packages/experimental/src/EventJournal.ts b/packages/experimental/src/EventJournal.ts index 4126ff20e49..6d348768d48 100644 --- a/packages/experimental/src/EventJournal.ts +++ b/packages/experimental/src/EventJournal.ts @@ -431,7 +431,7 @@ export const makeIndexedDb = (options?: { if (state.done) return const remoteEntry = state.value const entry = remoteEntry.entry - entries.get(entry.id).onsuccess = (event) => { + entries.get(entry.id as Uint8Array).onsuccess = (event) => { if ((event.target as any).result) { remotes.put({ remoteId: options.remoteId, @@ -516,7 +516,7 @@ export const makeIndexedDb = (options?: { const remotesStore = tx.objectStore("remotes") const remoteEntryIdStore = tx.objectStore("remoteEntryId") - remoteEntryIdStore.get(remoteId).onsuccess = (event) => { + remoteEntryIdStore.get(remoteId as Uint8Array).onsuccess = (event) => { const startEntryId = (event.target as any).result?.entryId const entryCursor = entriesStore.index("id").openCursor( startEntryId ? IDBKeyRange.lowerBound(startEntryId, true) : null, @@ -526,7 +526,7 @@ export const makeIndexedDb = (options?: { const cursor = entryCursor.result if (!cursor) return const entry = decodeEntryIdb(cursor.value) - remotesStore.get([remoteId, entry.id]).onsuccess = (event) => { + remotesStore.get([remoteId as Uint8Array, entry.id as Uint8Array]).onsuccess = (event) => { if (!(event.target as any).result) entries.push(entry) cursor.continue() } diff --git a/packages/experimental/src/EventLogEncryption.ts b/packages/experimental/src/EventLogEncryption.ts index d098c228eaf..75ac3141911 100644 --- a/packages/experimental/src/EventLogEncryption.ts +++ b/packages/experimental/src/EventLogEncryption.ts @@ -73,7 +73,7 @@ export const makeEncryptionSubtle = (crypto: Crypto): Effect.Effect crypto.subtle.importKey( "raw", - Redacted.value(identity.privateKey), + Redacted.value(identity.privateKey) as Uint8Array, "AES-GCM", true, ["encrypt", "decrypt"] @@ -93,7 +93,7 @@ export const makeEncryptionSubtle = (crypto: Crypto): Effect.Effect Promise.all( - data.map((entry) => crypto.subtle.encrypt({ name: "AES-GCM", iv, tagLength: 128 }, key, entry)) + data.map((entry) => crypto.subtle.encrypt({ name: "AES-GCM", iv, tagLength: 128 }, key, entry as Uint8Array)) ) ) return { @@ -107,9 +107,9 @@ export const makeEncryptionSubtle = (crypto: Crypto): Effect.Effect Promise.all(entries.map((data) => crypto.subtle.decrypt( - { name: "AES-GCM", iv: data.iv, tagLength: 128 }, + { name: "AES-GCM", iv: data.iv as Uint8Array, tagLength: 128 }, key, - data.encryptedEntry + data.encryptedEntry as Uint8Array ) )) )).map((buffer) => new Uint8Array(buffer)) @@ -117,12 +117,12 @@ export const makeEncryptionSubtle = (crypto: Crypto): Effect.Effect new RemoteEntry({ remoteSequence: entries[i].sequence, entry })) }), sha256: (data) => - Effect.promise(() => crypto.subtle.digest("SHA-256", data)).pipe( + Effect.promise(() => crypto.subtle.digest("SHA-256", data as Uint8Array)).pipe( Effect.map((hash) => new Uint8Array(hash)) ), sha256String: (data) => Effect.map( - Effect.promise(() => crypto.subtle.digest("SHA-256", data)), + Effect.promise(() => crypto.subtle.digest("SHA-256", data as Uint8Array)), (hash) => { const hashArray = Array.from(new Uint8Array(hash)) const hashHex = hashArray diff --git a/packages/platform-browser/src/internal/httpClient.ts b/packages/platform-browser/src/internal/httpClient.ts index 74139107690..9f3ced8e9d1 100644 --- a/packages/platform-browser/src/internal/httpClient.ts +++ b/packages/platform-browser/src/internal/httpClient.ts @@ -91,7 +91,7 @@ const sendBody = ( case "Raw": return Effect.sync(() => xhr.send(body.body as any)) case "Uint8Array": - return Effect.sync(() => xhr.send(body.body)) + return Effect.sync(() => xhr.send(body.body as Uint8Array)) case "FormData": return Effect.sync(() => xhr.send(body.formData)) case "Stream": @@ -274,7 +274,7 @@ export abstract class IncomingMessageImpl extends Inspectable.Class }).pipe( Effect.map((response) => { if (typeof response === "string") { - return encoder.encode(response).buffer + return encoder.encode(response).buffer as ArrayBuffer } return response }), diff --git a/packages/platform-node/src/internal/httpIncomingMessage.ts b/packages/platform-node/src/internal/httpIncomingMessage.ts index e89a78032aa..4876511649a 100644 --- a/packages/platform-node/src/internal/httpIncomingMessage.ts +++ b/packages/platform-node/src/internal/httpIncomingMessage.ts @@ -87,7 +87,7 @@ export abstract class HttpIncomingMessageImpl extends Inspectable.Class NodeStream.toUint8Array(() => this.source, { onFailure: this.onError, maxBytes: Option.getOrUndefined(maxBodySize) - }) + }).pipe(Effect.map((_) => _.buffer as ArrayBuffer)) ) } } From 192ff6b7591666d214eeeeccd034f88fa0f06f94 Mon Sep 17 00:00:00 2001 From: Sebastian Lorenz Date: Thu, 8 May 2025 10:50:59 +0200 Subject: [PATCH 2/3] add changeset --- .changeset/silly-keys-cheer.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/silly-keys-cheer.md diff --git a/.changeset/silly-keys-cheer.md b/.changeset/silly-keys-cheer.md new file mode 100644 index 00000000000..b1f1e75198d --- /dev/null +++ b/.changeset/silly-keys-cheer.md @@ -0,0 +1,8 @@ +--- +"@effect/platform-browser": patch +"@effect/platform-node": patch +"@effect/experimental": patch +"effect": patch +--- + +Support building under TypeScript 5.9 From d427dcc2aafec54d2a2236895bdccd0e719ad70e Mon Sep 17 00:00:00 2001 From: Sebastian Lorenz Date: Thu, 8 May 2025 10:51:38 +0200 Subject: [PATCH 3/3] formatting --- packages/experimental/src/EventJournal.ts | 4 +++- packages/experimental/src/EventLogEncryption.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/experimental/src/EventJournal.ts b/packages/experimental/src/EventJournal.ts index 6d348768d48..616c09e32c7 100644 --- a/packages/experimental/src/EventJournal.ts +++ b/packages/experimental/src/EventJournal.ts @@ -526,7 +526,9 @@ export const makeIndexedDb = (options?: { const cursor = entryCursor.result if (!cursor) return const entry = decodeEntryIdb(cursor.value) - remotesStore.get([remoteId as Uint8Array, entry.id as Uint8Array]).onsuccess = (event) => { + remotesStore.get([remoteId as Uint8Array, entry.id as Uint8Array]).onsuccess = ( + event + ) => { if (!(event.target as any).result) entries.push(entry) cursor.continue() } diff --git a/packages/experimental/src/EventLogEncryption.ts b/packages/experimental/src/EventLogEncryption.ts index 75ac3141911..d0188cc6abc 100644 --- a/packages/experimental/src/EventLogEncryption.ts +++ b/packages/experimental/src/EventLogEncryption.ts @@ -93,7 +93,9 @@ export const makeEncryptionSubtle = (crypto: Crypto): Effect.Effect Promise.all( - data.map((entry) => crypto.subtle.encrypt({ name: "AES-GCM", iv, tagLength: 128 }, key, entry as Uint8Array)) + data.map((entry) => + crypto.subtle.encrypt({ name: "AES-GCM", iv, tagLength: 128 }, key, entry as Uint8Array) + ) ) ) return {