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-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-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") }) {}