From 8a29753e0dc2bfab7c13922c99b2b6f1bdbf7029 Mon Sep 17 00:00:00 2001 From: Mattia Manzati Date: Tue, 16 Dec 2025 12:48:43 +0100 Subject: [PATCH] Add test for ensuring typeConstructor is attached --- .changeset/curly-mice-march.md | 5 +++++ packages/effect/src/Schema.ts | 1 + .../effect/test/Schema/Schema/annotations.test.ts | 12 ++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 .changeset/curly-mice-march.md diff --git a/.changeset/curly-mice-march.md b/.changeset/curly-mice-march.md new file mode 100644 index 00000000000..91989343e24 --- /dev/null +++ b/.changeset/curly-mice-march.md @@ -0,0 +1,5 @@ +--- +"effect": patch +--- + +Add test for ensuring typeConstructor is attached diff --git a/packages/effect/src/Schema.ts b/packages/effect/src/Schema.ts index 885e36ca166..db74f0387a6 100644 --- a/packages/effect/src/Schema.ts +++ b/packages/effect/src/Schema.ts @@ -231,6 +231,7 @@ interface AllAnnotations> {} const builtInAnnotations = { + typeConstructor: AST.TypeConstructorAnnotationId, schemaId: AST.SchemaIdAnnotationId, message: AST.MessageAnnotationId, missingMessage: AST.MissingMessageAnnotationId, diff --git a/packages/effect/test/Schema/Schema/annotations.test.ts b/packages/effect/test/Schema/Schema/annotations.test.ts index 3da762bcac3..e2ea1672a88 100644 --- a/packages/effect/test/Schema/Schema/annotations.test.ts +++ b/packages/effect/test/Schema/Schema/annotations.test.ts @@ -1,5 +1,6 @@ import { describe, it } from "@effect/vitest" import { assertTrue, deepStrictEqual, strictEqual } from "@effect/vitest/utils" +import * as Option from "effect/Option" import type * as ParseResult from "effect/ParseResult" import type * as Pretty from "effect/Pretty" import * as S from "effect/Schema" @@ -81,6 +82,17 @@ describe(".annotations()", () => { }) }) + it("typeConstructor", () => { + const schema = S.Struct({ a: S.String }).annotations({ typeConstructor: { _tag: "MyTypeConstructor" } }) + deepStrictEqual(schema.ast.annotations, { + [AST.TypeConstructorAnnotationId]: { _tag: "MyTypeConstructor" } + }) + deepStrictEqual( + AST.getTypeConstructorAnnotation(schema.ast), + Option.some({ _tag: "MyTypeConstructor" }) + ) + }) + it("parseIssueTitle", async () => { const getOrderId = ({ actual }: ParseResult.ParseIssue) => { if (S.is(S.Struct({ id: S.Number }))(actual)) {