Effect CommunityEC
Effect Community2mo ago
16 replies
Florian

Issue with Annotation Merging in Schema Using Effect Library

I think I have a bug in schema when it comes to annotation merging.

Given the following playground: https://effect.website/play#56f34af72b3a

import { Effect, Schema, SchemaAST } from "effect";

const AccountNumber = Schema.NonEmptyString.annotations({
  examples: ["1300"],
  title: "Konto",
  description: "Konto",
});

const SomeSchema = Schema.Struct({
  number: AccountNumber,
}).annotations({
  title: "Foo",
  identifier: "Should be kept",
});

const SomeOtherSchema = SomeSchema.annotations({
  title: "Bar",
});

const a1 = SchemaAST.getIdentifierAnnotation(SomeSchema.ast); // Some
const a2 = SchemaAST.getIdentifierAnnotation(SomeOtherSchema.ast); // None

console.log({ a1, a2 });


The Playground gives me the correct Option.some for a2. This corresponds with the method description of Schema.annotations: "Merges a set of new annotations with existing ones, potentially overwriting any duplicates."

But when I run the code locally with effect@3.19.6 then I get "None" for a2. The playground uses an older version of effect.
Was this page helpful?