Schema: idiomatic way to encode against a type-erased `Schema.Top` (codec services show as `unknown` in the requirements channel)?
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- api
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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 |
- Ngôn ngữ chính
- TypeScript
- Star
- 16.7k
- Fork
- 808
- Merge trung bình
- 11 giờ 33 phút
- Pull request đã merge (30 ngày)
- 855
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Effect-TS/effect
-
`fromJsonSchemaDocument`: import open `patternProperties`Có thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Effect-TS/effect#10048 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`fromJsonSchemaDocument`: intersect an object with `anyOf` branches that re-declare an enum propertyĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`fromJsonSchemaDocument`: import `dependentRequired` (draft-07 `dependencies`)Có thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Effect-TS/effect#10046 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`fromJsonSchemaDocument`: import `if` / `then` / `else`Có thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Effect-TS/effect#10045 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`fromJsonSchemaDocument`: import the `not` keywordCó thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Effect-TS/effect#10044 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Effect-TS/effect
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
scaleway/ultraviolet#7089 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
tencent-connect/dsh-qqbot#81 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Pen taps on sidebar rows start a drag and lose their clickCó thể đã có người làm @makhnatkin đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
clangd/vscode-clangd#1009 ·