diff --git a/packages/effect/src/SchemaAST.ts b/packages/effect/src/SchemaAST.ts index 4befd23444..1d27f129b3 100644 --- a/packages/effect/src/SchemaAST.ts +++ b/packages/effect/src/SchemaAST.ts @@ -2183,18 +2183,15 @@ export const getPropertyKeyIndexedAccess = (ast: AST, name: PropertyKey): Proper case "Refinement": return getPropertyKeyIndexedAccess(ast.from, name) } - return new PropertySignature(name, neverKeyword, false, true) + throw new Error(errors_.getASTUnsupportedSchema(ast)) } const getPropertyKeys = (ast: AST): Array => { + const annotation = getSurrogateAnnotation(ast) + if (Option.isSome(annotation)) { + return getPropertyKeys(annotation.value) + } switch (ast._tag) { - case "Declaration": { - const annotation = getSurrogateAnnotation(ast) - if (Option.isSome(annotation)) { - return getPropertyKeys(annotation.value) - } - break - } case "TypeLiteral": return ast.propertySignatures.map((ps) => ps.name) case "Suspend": diff --git a/packages/effect/test/Schema/Schema/pick.test.ts b/packages/effect/test/Schema/Schema/pick.test.ts index 03563b7d09..f7801a9a2f 100644 --- a/packages/effect/test/Schema/Schema/pick.test.ts +++ b/packages/effect/test/Schema/Schema/pick.test.ts @@ -4,7 +4,7 @@ import { describe, expect, it } from "vitest" describe("pick", () => { it("Struct", async () => { - const a = Symbol.for("effect/Schema/test/a") + const a = Symbol.for("@effect/schema/test/a") const schema = S.Struct({ [a]: S.String, b: S.NumberFromString, c: S.Boolean }).pipe( S.pick(a, "b") ) @@ -113,22 +113,22 @@ describe("pick", () => { }) it("Record(symbol, number)", async () => { - const a = Symbol.for("effect/Schema/test/a") - const b = Symbol.for("effect/Schema/test/b") + const a = Symbol.for("@effect/schema/test/a") + const b = Symbol.for("@effect/schema/test/b") const schema = S.Record({ key: S.SymbolFromSelf, value: S.Number }).pipe(S.pick(a, b)) await Util.expectDecodeUnknownSuccess(schema, { [a]: 1, [b]: 2 }) await Util.expectDecodeUnknownFailure( schema, { [a]: "a", [b]: 2 }, - `{ readonly Symbol(effect/Schema/test/a): number; readonly Symbol(effect/Schema/test/b): number } -└─ [Symbol(effect/Schema/test/a)] + `{ readonly Symbol(@effect/schema/test/a): number; readonly Symbol(@effect/schema/test/b): number } +└─ [Symbol(@effect/schema/test/a)] └─ Expected number, actual "a"` ) await Util.expectDecodeUnknownFailure( schema, { [a]: 1, [b]: "b" }, - `{ readonly Symbol(effect/Schema/test/a): number; readonly Symbol(effect/Schema/test/b): number } -└─ [Symbol(effect/Schema/test/b)] + `{ readonly Symbol(@effect/schema/test/a): number; readonly Symbol(@effect/schema/test/b): number } +└─ [Symbol(@effect/schema/test/b)] └─ Expected number, actual "b"` ) })