Effect CommunityEC
Effect Community2y ago
5 replies
wayne

Extending a Schema Defined by `S.Class`

How do I extend a schema defined by S.Class?
Here's my code:
import * as S from '@effect/schema/Schema';

export class Quadruped extends S.Class<Quadruped>('Quadruped')({
    legs: S.Literal(4),
}) {}

export const Dog = S.extend(Quadruped)(
    S.Struct({
        tail: S.Literal(true),
    }),
);

And when I run this, I get the following runtime error:
Error: Extend: cannot extend `{ tail: true }` with `(Quadruped (Encoded side) <-
> Quadruped)` (path [])


If I define Quadruped as an S.Struct it works as expected.
Was this page helpful?