Bug: Unused bindings and leftover manual `_tag` handling in `effect/ai`, `ai-anthropic`, `effect/http`, and `effect/eventlog`
Summary
None of these are runtime bugs; they are small code-quality issues. A strict lint pass (Oxlint with eslint/no-unused-vars and the anti-slop ruleset) flagged them, and I checked each one by hand on main @ 95a3ab78e924c3270d7b4e2e0b144e3341fa7029. I grouped them into one issue so they don't each need their own.
Reproduction
- Check out
mainat 95a3ab78e924c3270d7b4e2e0b144e3341fa7029 and runpnpm install. - Run Oxlint with
eslint/no-unused-varsset toerroron the files below, e.g.pnpm exec oxlint -A all -D eslint/no-unused-vars -f unix packages/ai/anthropic/src/AnthropicLanguageModel.ts packages/effect/src/ai/AnthropicStructuredOutput.ts. - Items 3–4 come from reading the code; they aren't lint errors under the repo's current config.
Actual behavior
- Unused destructured binding:
packages/ai/anthropic/src/AnthropicLanguageModel.ts:1163const { type, ...params } = part.paramstypeis declared but never read. The destructuring is there to striptypefromparamsbefore they become theserver_tool_useinput, so the behavior is fine, but the unused binding is reported. - Imports used only in JSDoc:
packages/effect/src/ai/AnthropicStructuredOutput.ts:17-18
The only references are inimport * as LanguageModel from "./LanguageModel.ts" import * as OpenAiStructuredOutput from "./OpenAiStructuredOutput.ts"{@link ...}tags on lines 49–50. Because these are value imports, they become real module dependencies ofAnthropicStructuredOutputand are reported as unused. - Broad
catchIfthat checks_tagby hand:packages/effect/src/http/HttpStaticServer.ts:425
and(error): error is PlatformError => error.reason._tag === "NotFound",packages/effect/src/eventlog/SqlEventJournal.ts:246(e) => e._tag !== "EventJournalError", - Hidden type mismatch behind a double cast:
packages/effect/src/ai/internal/mcpRuntime.ts:467!((admission.protocol as unknown as McpProtocol.ProtocolAdapter).handlerRpcs?.requests.has(
Expected behavior
- Drop the binding without changing behavior, e.g.
const { type: _type, ...params } = part.params(if_-prefixed names are allowed) or another omit helper. - Either use
import type(if the docs tooling resolves{@link}through type-only imports) or link by module path, so the runtime module graph has no unused value imports. - Possible cleanup: use the tagged-error combinators (
Effect.catchTag/catchTags, orcatchReasonforPlatformErrorreasons) instead of comparing_tagstrings, provided behavior stays the same. In particular,NotFound→ route-not-found and everything else → internal server error. - Possible cleanup: type
admission.protocolas (or narrow it to)ProtocolAdapterso theas unknown ascast is no longer needed.
Environment
- Version/commit:
effect4.0.3 /@effect/ai-anthropic4.0.3,main@ 95a3ab78e924c3270d7b4e2e0b144e3341fa7029 - OS: Ubuntu 22.04.5 LTS, Node v24.21.0
- Relevant configuration: Oxlint 1.86.0 (the repo's version) with
eslint/no-unused-vars, plus anti-slop @ c44ef22ca116d0ba62a3ff663a0bd13a3f3fa40b. The repo's default.oxlintrc.jsonreports none of these.
Evidence
Code references are linked above. All of them were checked against main @ 95a3ab78e924c3270d7b4e2e0b144e3341fa7029.
Oxlint output for items 1–2 (pnpm exec oxlint -A all -D eslint/no-unused-vars <files> -f unix):
packages/effect/src/ai/AnthropicStructuredOutput.ts:17:13: Identifier 'LanguageModel' is imported but never used. [Error/eslint(no-unused-vars)]
packages/effect/src/ai/AnthropicStructuredOutput.ts:18:13: Identifier 'OpenAiStructuredOutput' is imported but never used. [Error/eslint(no-unused-vars)]
packages/ai/anthropic/src/AnthropicLanguageModel.ts:1163:31: Variable 'type' is declared but never used. Unused variables should start with a '_'. [Error/eslint(no-unused-vars)]
Additional context
- Confirmed: items 1 and 2 are unused bindings or imports. Item 3 compares
_tagstrings by hand. Item 4 uses anas unknown ascast. - Not claimed: none of these changes runtime behavior. Items 3 and 4 are refactoring suggestions, and I haven't checked whether the existing combinators can express item 3 exactly.
- For context, the rest of the anti-slop output (about 55k diagnostics, mostly spacing, safety comments on type assertions, and
_tagstyle) looked intentional or stylistic: the non-empty array casts inSocket,DatagramSocket,Channel, andStreamare guarded by length checks, andReflect.*in the Proxy traps is correct. I'm not raising any of that.
Correction after a duplicate search: I'm withdrawing the SqlEventJournal.ts:246 part of item 3. Closed PR #8314 (which followed #7843 / #7844) proposed removing this same catchIf(e => e._tag !== "EventJournalError", ...) wrapping in writeFromRemote, and it was closed with the note that these methods don't need generic errors. The wrapping is intentional.
Items 1, 2, 4, and the HttpStaticServer.ts:425 part of item 3 still stand. I found no existing issues or PRs that cover them.