Effect CommunityEC
Effect Community3y ago
5 replies
hipnotic3141

Using an interface to extract types from a schema in effect schema documentation

I noticed in the effect schema documentation the part demonstrating how to extract types from a schema is using an interface rather than just keeping the type
import * as S from "@effect/schema/Schema";

interface Person extends S.Schema.To<typeof Person> {}
/*
Equivalent to:
interface Person {
  readonly name: string;
  readonly age: number;
}
*/

Is there a specific reason why it's better to use an interface vs a type for Person?
Was this page helpful?