Effect CommunityEC
Effect Communityโ€ข2y agoโ€ข
49 replies
Kroeber

Runtime Error on Extending Structs with Filter in TypeScript

Hi, seem to be running into some kind of technical limitation, but I'm not sure which one exactly. When I try to extend a Struct that has been refined through a filter function with another struct, I encounter the following runtime error:

Error: Extend: cannot extend `B` with `A` (path [])


Repro:

import { Schema as S } from "@effect/schema";

const A = S.Struct({ a: S.String }).pipe(S.filter(() => true)).annotations({ identifier: "A" });
const B = S.Struct({ b: S.String }).annotations({ identifier: "B" });
const C = S.extend(A, B).annotations({ identifier: "C" });
Was this page helpful?