Schema: idiomatic way to encode against a type-erased `Schema.Top` (codec services show as `unknown` in the requirements channel)?
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- api
調査の方向性
Start with the Schema.Top, Schema.toCodecJson, Schema.encodeUnknownEffect, encodeUnknownExit, and encodeUnknownResult APIs, then run the linked reproduction with bun install and bun run repro. Compare the reported R=unknown and R=never assertions and runtime check; done would require an agreed idiomatic way to encode or decode service-free type-erased schemas without an unsafe cast.
索引モデルが issue の本文から書いたものです。
説明
This is a usage/idiom question about encoding against type-erased schemas.
When you only have a type-erased Schema.Top — e.g. from RPC dynamic dispatch, heterogeneous registries, or plugin systems where the concrete schema type is lost — encoding a value against it as JSON surfaces unknown in the requirements (R) channel:
declare const erased: Schema.Top
const eff = Schema.encodeUnknownEffect(Schema.toCodecJson(erased))(value)
// eff: Effect<Json, SchemaError, unknown> // <- unknown in R
Schema.Top types DecodingServices/EncodingServices as unknown, and toCodecJson + encodeUnknownEffect forward them into R. @effect/language-service flags it as anyUnknownInErrorContext (TS377030, "unknown in the requirements channel"). But such schemas are plain data — they need no codec services (the repro verifies this at runtime).
The only clean fix we found is an unsafe cast asserting the (true) never service channels:
Schema.toCodecJson(erased as Schema.Codec<unknown, unknown, never, never>)
// -> Effect<Json, SchemaError, never>
We confirmed encodeUnknownExit / encodeUnknownResult (which return Exit/Result with no R channel) don't avoid the cast — their ConstraintEncoder<unknown> bound requires EncodingServices extends never, which Schema.Top doesn't satisfy.
Question: is casting the service channels the idiomatic way to encode/decode against a Schema.Top known to need no services, or is there a cleaner, more Effect-native API for this (a service-erasing combinator, an encode variant that ignores services, a better way to type-erase RPC schemas, etc.)?
Reproduction
https://github.com/schickling-repros/2026-07-effect-erased-schema-services
bun install
bun run repro # tsc type-assertions (R=unknown vs R=never) + a runtime check
Versions
- effect:
4.0.0-beta.98 @effect/language-service:anyUnknownInErrorContext(TS377030)
Context: this arises encoding RPC exit/payload schemas after dynamic dispatch erases them to Schema.Top — a follow-on to #6064 (which exposed successSchema but not the service-typing question).
Posted on behalf of @schickling
| field | value |
|---|---|
agent_name |
🌲 cl1-pine |
agent_session_id |
b9f1f4a5-dd10-40f6-b25c-945e71e2007a |
agent_tool |
Claude Code |
agent_tool_version |
2.1.206 |
agent_runtime |
Claude Code 2.1.206 |
agent_model |
claude-opus-4-8 |
runtime_profile |
/nix/store/1n76sy6i9y3ki3k4w04jksqvygw67sj0-coding-agent-runtime-profile/share/coding-agents/profile.json |
skills_manifest |
/nix/store/jn6r0r7r59x3a525jch4pwzwykszqp60-agent-skills-corpus/share/agent-skills/manifest.json |
worktree |
livestore/schickling/2026-07-17-refactor |
machine |
dev3 |
tooling_profile |
dotfiles@4eac376 |
- 主要言語
- TypeScript
- スター
- 16.7k
- フォーク
- 808
- 平均マージ
- 10時間 49分
- マージ済み PR(30日)
- 846
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Effect-TS/effect のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
add first-class support for skills extension in McpServer対応中かも @effect-bot が今日担当しました。 オープンenhancement
Effect-TS/effect#10016 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
SqlEventJournal: remote catch-up exceeds SQLite's bind-variable limit対応中かも @effect-bot が今日担当しました。 オープン
Effect-TS/effect#10012 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
AI providers drop the cause of a transport failure from `NetworkError`対応中かも @effect-bot が今日担当しました。 オープン
Effect-TS/effect#9983 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
Effect-TS/effect の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
keptinventory/kept#336 ·
メンテナーはふだん 1 日以内に返信
-
good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
hemi-earn
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
vetro-protocol/vetro-monorepo#1013 ·
メンテナーはふだん 1 日以内に返信