shorthand for mapping over tagged union schema

Aperta
#10,286 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@effect-bot ci sta già lavorando.

Dal 2/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement
What is the problem this feature would solve?

A more concise way to express cases such as the following:

import { Record, Schema as S, Tuple } from "effect"

import { ModuleSpecifier, RecoveryInstruction } from "../schema/index.ts"
import { DiagnosticOrigin } from "./DiagnosticOrigin.ts"

/** A diagnostic for an observed extension failure; interruption is cancellation and creates no extension diagnostic. */
export type Diagnostic = typeof Diagnostic.Type
export const Diagnostic = S.TaggedUnion({
  Error: {
    /** Safe, normalized failure details when remediation is unknown; excludes raw error objects and source excerpts. */
    error: S.NonEmptyString.check(S.isPattern(/\S/u)).annotate({
      description:
        "Safe, normalized failure details when remediation is unknown; excludes raw error objects and source excerpts."
    })
  },
  Instruction: {
    /** Actionable remediation including relevant failure context, replacing standalone error details. */
    instruction: RecoveryInstruction.annotateKey({
      description: "Actionable remediation including relevant failure context, replacing standalone error details."
    })
  }
})
  .pipe((schema) => S.Union(Record.values(schema.cases)))
  .mapMembers(
    Tuple.map(
      S.fieldsAssign({
        /** The configured segmenter or enrichment module that failed. */
        module: ModuleSpecifier.annotateKey({
          description: "The configured segmenter or enrichment module that failed."
        }),
        /** The extension kind and lifecycle stage: setup origins have no location, segmenter execution references a supplied change, and enrichment execution references a trait-local input. */
        origin: DiagnosticOrigin
      })
    )
  )
  .annotate({
    description:
      "A diagnostic for an observed extension failure; interruption is cancellation and creates no extension diagnostic."
  })
  .pipe(S.toTaggedUnion("_tag"))
What is the feature you are proposing to solve the problem?

Not sure what the exact API would look like––but ideally one wouldn't need to turn the initial tagged union schema into a union schema (in order to map its members) and then turn it back into a tagged union schema.

What alternatives have you considered?

No response

Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
11h 3m
PR unite (30g)
840

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.