Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

docs: TSchema guide is missing Union, TaggedStruct, Literal, Tuple, Boolean, and Struct options

未关闭
#153 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
停滞
技术栈
typescript
领域
documentation

调研方向

从 docs/content/docs/encoding/tschema.mdx 及其中现有的 TSchema 示例开始,然后将每个缺失的构造和选项映射到一个子章节。添加可编译的 twoslash 示例,解释 Union、Variant 和 TaggedStruct 之间的 CBOR 差异,最后给出所要求的页面结构和最佳实践指导。

由索引模型根据 Issue 内容生成。

描述

documentation enhancement

Problem

The TSchema guide page at `docs/content/docs/encoding/tschema.mdx` covers basic schemas (ByteArray, Integer, Struct, Variant, Array, Map, UndefinedOr) and codec creation, but is missing documentation for several important constructs and usage areas.

Missing Sections

Union — `TSchema.Union()` is the lower-level primitive that `Variant`, `TaggedStruct`, and other helpers are all built on. It is never documented on its own or explained in terms of when you'd reach for it directly over the helpers.

TaggedStruct — `TSchema.TaggedStruct()` creates discriminated unions with an explicit tag field (`_tag`, `type`, `kind`, `variant`). Auto-detection of tag fields inside `Union` members is a key feature that is not mentioned anywhere in the guide.

Literal — `TSchema.Literal()` for enum-style constructors with no fields. The `LiteralOptions` interface (`index`, `flatInUnion`) is not covered.

Tuple — `TSchema.Tuple()` for fixed-length positional data. No mention in the guide.

Boolean — `TSchema.Boolean` for Plutus-style booleans (Constr 0 = False, Constr 1 = True).

NullOr vs UndefinedOr — The guide only covers `UndefinedOr`. `NullOr` and the decision between them is absent.

Struct options — `flatFields`, `flatInUnion`, and `index` options on `TSchema.Struct()` are undocumented. These are critical for correctly matching Aiken on-chain encoding.

Variant vs Union vs TaggedStruct — No comparison section explaining when to use each and how they differ in CBOR encoding:

  • Variant: wrapper-object shape (`{ VerificationKey: { hash } }`) — single-level CBOR
  • TaggedStruct: discriminator-field shape (`{ _tag: "Mint", amount }`) — tag stripped in CBOR
  • Union: raw position-based — constructor index determines variant

Schema utilities — `compose`, `filter`, `equivalence`, and `is` are exported but absent from the guide.

Acceptance Criteria
  • Each missing schema type has its own subsection with description and code example
  • A comparison section for Union vs Variant vs TaggedStruct with CBOR encoding differences
  • Struct options (`flatFields`, `flatInUnion`, `index`) documented with encoding examples
  • All examples use `twoslash` code fences and compile
  • Page structure: Overview → Quick Start → Core Concepts → Reference → Best Practices
主要语言
TypeScript
星标
22
派生
31
平均合并
2 天 19 小时
30 天内合并 PR
32

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

IntersectMBO/evolution-sdk 的其他 Issue

查看 IntersectMBO/evolution-sdk 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。