Skip to content

Align Schema.toTaggedUnion.match with Data.taggedEnum.#1620

Merged
gcanti merged 4 commits intomainfrom
kit/tagged-union-match-unify
Mar 10, 2026
Merged

Align Schema.toTaggedUnion.match with Data.taggedEnum.#1620
gcanti merged 4 commits intomainfrom
kit/tagged-union-match-unify

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • Align Schema.toTaggedUnion(...).match with Data.taggedEnum.$match by inferring return types from the full cases object and applying Unify.
  • Allow matches where branches return distinct Effect types, e.g. Effect.succeed(\"ok\") and Effect.fail(\"nope\"), which now typecheck and unify correctly.
  • Add a dtslint regression test plus a patch changeset.

Testing

  • bun run test-types -- packages/effect/dtslint/schema/Union.tst.ts
  • bun run test-types (currently fails on unrelated existing dtslint exact-type assertions in packages/effect/dtslint/Types.tst.ts, packages/effect/dtslint/schema/Struct.tst.ts, packages/effect/dtslint/schema/api.tst.ts, and packages/effect/dtslint/schema/toIso.tst.ts)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: fcdb822

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitlangton kitlangton marked this pull request as ready for review March 5, 2026 13:52
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 5, 2026

📊 JSDoc Documentation Analysis

📈 Current Analysis Results
Analyzing 134 TypeScript files in packages/effect/src/ (including schema and config subdirectories)...

============================================================
         EFFECT JSDOC ANALYSIS REPORT
============================================================

📊 SUMMARY STATISTICS
------------------------------
Total files analyzed: 134
Total exported members: 4221
Missing @example: 2075 (49.2%)
Missing @category: 454 (10.8%)

🎯 TOP FILES NEEDING ATTENTION
----------------------------------------
1. Schema.ts
   📝 482 missing examples, 🏷️  268 missing categories
   📦 482 total exports
2. Array.ts
   📝 135 missing examples, 🏷️  2 missing categories
   📦 140 total exports
3. SchemaRepresentation.ts
   📝 96 missing examples, 🏷️  12 missing categories
   📦 96 total exports
4. SchemaAST.ts
   📝 77 missing examples, 🏷️  21 missing categories
   📦 77 total exports
5. Channel.ts
   📝 79 missing examples, 🏷️  0 missing categories
   📦 150 total exports
6. Cause.ts
   📝 75 missing examples, 🏷️  2 missing categories
   📦 75 total exports
7. Option.ts
   📝 66 missing examples, 🏷️  3 missing categories
   📦 66 total exports
8. Sink.ts
   📝 64 missing examples, 🏷️  2 missing categories
   📦 81 total exports
9. SchemaTransformation.ts
   📝 37 missing examples, 🏷️  26 missing categories
   📦 37 total exports
10. Predicate.ts
   📝 57 missing examples, 🏷️  0 missing categories
   📦 57 total exports
11. SchemaGetter.ts
   📝 49 missing examples, 🏷️  0 missing categories
   📦 49 total exports
12. Result.ts
   📝 46 missing examples, 🏷️  0 missing categories
   📦 46 total exports
13. Config.ts
   📝 34 missing examples, 🏷️  5 missing categories
   📦 34 total exports
14. Types.ts
   📝 39 missing examples, 🏷️  0 missing categories
   📦 39 total exports
15. Effect.ts
   📝 31 missing examples, 🏷️  2 missing categories
   📦 256 total exports

✅ PERFECTLY DOCUMENTED FILES
-----------------------------------
   Chunk.ts (86 exports)
   Clock.ts (5 exports)
   FiberHandle.ts (15 exports)
   FiberMap.ts (19 exports)
   FiberSet.ts (14 exports)
   HKT.ts (4 exports)
   HashMap.ts (44 exports)
   HashSet.ts (21 exports)
   Latch.ts (3 exports)
   Match.ts (57 exports)
   MutableHashSet.ts (9 exports)
   MutableRef.ts (17 exports)
   NonEmptyIterable.ts (3 exports)
   Random.ts (9 exports)
   Redacted.ts (9 exports)
   RegExp.ts (3 exports)
   Symbol.ts (1 exports)
   Trie.ts (29 exports)
   TxChunk.ts (22 exports)
   TxDeferred.ts (7 exports)
   TxHashMap.ts (41 exports)
   TxHashSet.ts (24 exports)
   TxPriorityQueue.ts (19 exports)
   TxReentrantLock.ts (18 exports)
   TxRef.ts (7 exports)
   TxSemaphore.ts (14 exports)
   TxSubscriptionRef.ts (12 exports)
   Unify.ts (8 exports)
   index.ts (0 exports)

🔍 SAMPLE MISSING ITEMS FROM Schema.ts
-----------------------------------
   Optionality (type, line 65): missing example, category
   Mutability (type, line 72): missing example, category
   ConstructorDefault (type, line 79): missing example, category
   MakeOptions (interface, line 87): missing example, category
   Bottom (interface, line 111): missing example, category
   declareConstructor (interface, line 164): missing example, category
   declareConstructor (function, line 188): missing example
   declare (interface, line 212): missing example
   declare (function, line 221): missing example, category
   revealBottom (function, line 241): missing example, category

📋 BREAKDOWN BY EXPORT TYPE
-----------------------------------
const: 1064 missing examples, 130 missing categories
interface: 319 missing examples, 132 missing categories
type: 240 missing examples, 74 missing categories
function: 345 missing examples, 97 missing categories
namespace: 48 missing examples, 20 missing categories
class: 59 missing examples, 1 missing categories

📈 DOCUMENTATION PROGRESS
------------------------------
Examples: 2146/4221 (50.8% complete)
Categories: 3767/4221 (89.2% complete)

============================================================
Analysis complete! 2529 items need attention.
============================================================

📄 Detailed results saved to: jsdoc-analysis-results.json

This comment is automatically updated on each push. View the analysis script for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 5, 2026

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.37 KB 6.37 KB 0.00 KB (0.00%)
batching.ts 8.53 KB 8.53 KB 0.00 KB (0.00%)
brand.ts 6.29 KB 6.29 KB 0.00 KB (0.00%)
cache.ts 9.69 KB 9.69 KB 0.00 KB (0.00%)
config.ts 16.73 KB 16.73 KB 0.00 KB (0.00%)
differ.ts 15.09 KB 15.09 KB 0.00 KB (0.00%)
http-client.ts 19.13 KB 19.13 KB 0.00 KB (0.00%)
logger.ts 8.86 KB 8.86 KB 0.00 KB (0.00%)
metric.ts 8.22 KB 8.22 KB 0.00 KB (0.00%)
optic.ts 7.54 KB 7.54 KB 0.00 KB (0.00%)
pubsub.ts 13.36 KB 13.36 KB 0.00 KB (0.00%)
queue.ts 10.57 KB 10.57 KB 0.00 KB (0.00%)
schedule.ts 9.95 KB 9.95 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 24.39 KB 24.39 KB 0.00 KB (0.00%)
schema-string-transformation.ts 11.65 KB 11.65 KB 0.00 KB (0.00%)
schema-string.ts 9.94 KB 9.94 KB 0.00 KB (0.00%)
schema-template-literal.ts 12.56 KB 12.56 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 16.79 KB 16.79 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 19.47 KB 19.47 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 15.96 KB 15.96 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 15.94 KB 15.94 KB 0.00 KB (0.00%)
schema-toFormatter.ts 15.79 KB 15.79 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 18.23 KB 18.23 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 16.35 KB 16.35 KB 0.00 KB (0.00%)
schema.ts 15.42 KB 15.42 KB 0.00 KB (0.00%)
stm.ts 11.49 KB 11.49 KB 0.00 KB (0.00%)
stream.ts 8.77 KB 8.77 KB 0.00 KB (0.00%)

@IMax153 IMax153 requested a review from gcanti March 10, 2026 14:51
@gcanti gcanti merged commit 7517908 into main Mar 10, 2026
15 checks passed
@gcanti gcanti deleted the kit/tagged-union-match-unify branch March 10, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants