From e65dacc7b3fe6a2d25331ebd0093c606a2aadf5b Mon Sep 17 00:00:00 2001 From: Tim Smart Date: Mon, 2 Nov 2026 20:58:58 +0000 Subject: [PATCH 1/2] Fix type errors reported by TypeScript 7.1 --- packages/effect/src/SchemaAST.ts | 2 +- packages/effect/src/graphql/GraphQL.ts | 11 +++++++---- packages/effect/src/http/HttpClient.ts | 9 ++++++++- packages/effect/src/schema/SchemaCompiler/runtime.ts | 2 +- packages/platform/browser/test/fixtures/rpc-e2e.ts | 9 +++++---- packages/platform/node/test/fixtures/rpc-e2e.ts | 9 +++++---- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/packages/effect/src/SchemaAST.ts b/packages/effect/src/SchemaAST.ts index 87d56ea662a..6d74fbe4eab 100644 --- a/packages/effect/src/SchemaAST.ts +++ b/packages/effect/src/SchemaAST.ts @@ -3119,7 +3119,7 @@ export const Objects: new( pending: Effect.Effect ): Effect.Effect => { const property = properties![index] - return Effect.flatMap(Effect.exit(pending), (exit) => { + return Effect.flatMap(Effect.exit(pending), (exit): Effect.Effect => { // Copy the parsed prefix per execution so reruns cannot overwrite earlier results. const state: ObjectParserState = { ...snapshot, out: { ...snapshot.out } } const terminal = stepProperty(state, property, exit) diff --git a/packages/effect/src/graphql/GraphQL.ts b/packages/effect/src/graphql/GraphQL.ts index e15ebfbac96..724421191bd 100644 --- a/packages/effect/src/graphql/GraphQL.ts +++ b/packages/effect/src/graphql/GraphQL.ts @@ -245,7 +245,10 @@ const Proto = { // The middleware type of an operation is phantom and its Schemas are erased to // `Schema.Top` here, so the typed constructors below state their operation -// type with one assertion each. +// type with one assertion each. Each constructor also asserts to its own +// declared type: TypeScript 7.1 relates the `Variables` conditional in +// `makeOperation` to the one in the constructor's annotation structurally +// rather than by identity, and the structural check fails. const makeProto = (fields: Omit): Any => Object.assign(Object.create(Proto), fields) @@ -323,7 +326,7 @@ export const query: < readonly result: Result } ) => Operation<"query", Name, Variables extends Schema.Struct.Fields ? Schema.Struct : Variables, Result> = - makeOperation("query") + makeOperation("query") as typeof query /** * Defines a mutation. Same shape as {@link query}. @@ -363,7 +366,7 @@ export const mutation: < Name, Variables extends Schema.Struct.Fields ? Schema.Struct : Variables, Result -> = makeOperation("mutation") +> = makeOperation("mutation") as typeof mutation /** * Defines a subscription. The client method for a subscription returns a @@ -404,7 +407,7 @@ export const subscription: < Name, Variables extends Schema.Struct.Fields ? Schema.Struct : Variables, Result -> = makeOperation("subscription") +> = makeOperation("subscription") as typeof subscription /** * The `__typename` Schema for the "every other type" member of a generated diff --git a/packages/effect/src/http/HttpClient.ts b/packages/effect/src/http/HttpClient.ts index 0c5aa1472dd..88e933e27cc 100644 --- a/packages/effect/src/http/HttpClient.ts +++ b/packages/effect/src/http/HttpClient.ts @@ -418,12 +418,19 @@ export const catchTag: { ): HttpClient.With ? K[number] : K>, R1 | R> => transformResponse( self, + // TypeScript 7.1 does not relate the error type `Effect.catchTag` returns + // to the `ExcludeTag` declared here, because each declares its own copy + // of the conditional on `K`. The assertion restates the declared type. (effect) => Effect.catchTag( effect, tag, f - ) + ) as Effect.Effect< + HttpClientResponse.HttpClientResponse, + E1 | ExcludeTag ? K[number] : K>, + R | R1 + > ) ) diff --git a/packages/effect/src/schema/SchemaCompiler/runtime.ts b/packages/effect/src/schema/SchemaCompiler/runtime.ts index d2985054bf9..d85a6c92ea9 100644 --- a/packages/effect/src/schema/SchemaCompiler/runtime.ts +++ b/packages/effect/src/schema/SchemaCompiler/runtime.ts @@ -70,7 +70,7 @@ const makeObjectBase = ( pending: Effect.Effect ): Effect.Effect => { const property = properties![index] - return Effect.flatMap(Effect.exit(pending), (exit) => { + return Effect.flatMap(Effect.exit(pending), (exit): Effect.Effect => { // Each execution gets its own output; `issues` is still undefined here // because `errors: "all"` is routed to the fallback before suspending. const state: ObjectParserState = { ...snapshot, out: { ...snapshot.out } } diff --git a/packages/platform/browser/test/fixtures/rpc-e2e.ts b/packages/platform/browser/test/fixtures/rpc-e2e.ts index f615d80a5ce..fab3cbd864e 100644 --- a/packages/platform/browser/test/fixtures/rpc-e2e.ts +++ b/packages/platform/browser/test/fixtures/rpc-e2e.ts @@ -11,10 +11,11 @@ import * as RpcServer from "effect/rpc/RpcServer" import * as RpcTest from "effect/rpc/RpcTest" import { AuthClient, AuthLayer, TimingLayer, User, UserRpcs, UsersLayer } from "./rpc-schemas.ts" -export class UsersClient extends Context.Service< - UsersClient, - RpcClient.RpcClient, RpcClientError> ->()("UsersClient") { +// An interface rather than an inline type: TypeScript 7.1 cannot serialize the +// inferred class type otherwise (TS5088). +interface UsersClientService extends RpcClient.RpcClient, RpcClientError> {} + +export class UsersClient extends Context.Service()("UsersClient") { static readonly layer = Layer.effect(UsersClient)(RpcClient.make(UserRpcs)).pipe( Layer.provide(AuthClient) ) diff --git a/packages/platform/node/test/fixtures/rpc-e2e.ts b/packages/platform/node/test/fixtures/rpc-e2e.ts index 2e69f22dc52..55d257e9e11 100644 --- a/packages/platform/node/test/fixtures/rpc-e2e.ts +++ b/packages/platform/node/test/fixtures/rpc-e2e.ts @@ -11,10 +11,11 @@ import * as RpcServer from "effect/rpc/RpcServer" import * as RpcTest from "effect/rpc/RpcTest" import { AuthClient, AuthLayer, TimingLayer, User, UserRpcs, UsersLayer } from "./rpc-schemas.ts" -export class UsersClient extends Context.Service< - UsersClient, - RpcClient.RpcClient, RpcClientError> ->()("UsersClient") { +// An interface rather than an inline type: TypeScript 7.1 cannot serialize the +// inferred class type otherwise (TS5088). +interface UsersClientService extends RpcClient.RpcClient, RpcClientError> {} + +export class UsersClient extends Context.Service()("UsersClient") { static readonly layer = Layer.effect(UsersClient)(RpcClient.make(UserRpcs)).pipe( Layer.provide(AuthClient) ) From 6541f4cabd78af29aa7b5436fe3a895588981cb1 Mon Sep 17 00:00:00 2001 From: Tim Smart Date: Mon, 2 Nov 2026 22:10:32 +0000 Subject: [PATCH 2/2] Export Unauthorized in RPC fixtures instead of adding an interface --- packages/platform/browser/test/fixtures/rpc-e2e.ts | 9 ++++----- packages/platform/browser/test/fixtures/rpc-schemas.ts | 5 ++++- packages/platform/node/test/fixtures/rpc-e2e.ts | 9 ++++----- packages/platform/node/test/fixtures/rpc-schemas.ts | 5 ++++- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/platform/browser/test/fixtures/rpc-e2e.ts b/packages/platform/browser/test/fixtures/rpc-e2e.ts index fab3cbd864e..f615d80a5ce 100644 --- a/packages/platform/browser/test/fixtures/rpc-e2e.ts +++ b/packages/platform/browser/test/fixtures/rpc-e2e.ts @@ -11,11 +11,10 @@ import * as RpcServer from "effect/rpc/RpcServer" import * as RpcTest from "effect/rpc/RpcTest" import { AuthClient, AuthLayer, TimingLayer, User, UserRpcs, UsersLayer } from "./rpc-schemas.ts" -// An interface rather than an inline type: TypeScript 7.1 cannot serialize the -// inferred class type otherwise (TS5088). -interface UsersClientService extends RpcClient.RpcClient, RpcClientError> {} - -export class UsersClient extends Context.Service()("UsersClient") { +export class UsersClient extends Context.Service< + UsersClient, + RpcClient.RpcClient, RpcClientError> +>()("UsersClient") { static readonly layer = Layer.effect(UsersClient)(RpcClient.make(UserRpcs)).pipe( Layer.provide(AuthClient) ) diff --git a/packages/platform/browser/test/fixtures/rpc-schemas.ts b/packages/platform/browser/test/fixtures/rpc-schemas.ts index 0798660cfb2..98d32f76145 100644 --- a/packages/platform/browser/test/fixtures/rpc-schemas.ts +++ b/packages/platform/browser/test/fixtures/rpc-schemas.ts @@ -20,7 +20,10 @@ class StreamUsers extends Rpc.make("StreamUsers", { class CurrentUser extends Context.Service()("CurrentUser") {} -class Unauthorized extends Schema.Error("Unauthorized")({ +// Exported so declaration emit can name it. Error classes are yieldable, so a +// private one is a cycle that TypeScript 7.1 reports as TS5088 in `rpc-e2e.ts` +// (microsoft/TypeScript#64461). +export class Unauthorized extends Schema.Error("Unauthorized")({ _tag: Schema.tag("Unauthorized") }) {} diff --git a/packages/platform/node/test/fixtures/rpc-e2e.ts b/packages/platform/node/test/fixtures/rpc-e2e.ts index 55d257e9e11..2e69f22dc52 100644 --- a/packages/platform/node/test/fixtures/rpc-e2e.ts +++ b/packages/platform/node/test/fixtures/rpc-e2e.ts @@ -11,11 +11,10 @@ import * as RpcServer from "effect/rpc/RpcServer" import * as RpcTest from "effect/rpc/RpcTest" import { AuthClient, AuthLayer, TimingLayer, User, UserRpcs, UsersLayer } from "./rpc-schemas.ts" -// An interface rather than an inline type: TypeScript 7.1 cannot serialize the -// inferred class type otherwise (TS5088). -interface UsersClientService extends RpcClient.RpcClient, RpcClientError> {} - -export class UsersClient extends Context.Service()("UsersClient") { +export class UsersClient extends Context.Service< + UsersClient, + RpcClient.RpcClient, RpcClientError> +>()("UsersClient") { static readonly layer = Layer.effect(UsersClient)(RpcClient.make(UserRpcs)).pipe( Layer.provide(AuthClient) ) diff --git a/packages/platform/node/test/fixtures/rpc-schemas.ts b/packages/platform/node/test/fixtures/rpc-schemas.ts index 38614369c38..f3025776242 100644 --- a/packages/platform/node/test/fixtures/rpc-schemas.ts +++ b/packages/platform/node/test/fixtures/rpc-schemas.ts @@ -20,7 +20,10 @@ class StreamUsers extends Rpc.make("StreamUsers", { class CurrentUser extends Context.Service()("CurrentUser") {} -class Unauthorized extends Schema.Error("Unauthorized")({ +// Exported so declaration emit can name it. Error classes are yieldable, so a +// private one is a cycle that TypeScript 7.1 reports as TS5088 in `rpc-e2e.ts` +// (microsoft/TypeScript#64461). +export class Unauthorized extends Schema.Error("Unauthorized")({ _tag: Schema.tag("Unauthorized") }) {}