Effect CommunityEC
Effect Community•3y ago•
3 replies
wewell

Creating Generic Schema Classes with Validation Schemas

Hello 👋 Is there a way to make schema classes generic ?

I have tried something like this but I get a typescript error Base class expressions cannot reference class type parameters.

Or is there another way to create generic-types with validation schemas ?

import * as S from '@effect/schema/Schema';
import { CurrencyCode } from '../Currency';

export class Amount<C extends CurrencyCode> extends S.Class<Amount<C>>()({
  value: S.number,
  currency: S.enums(CurrencyCode),
}) {}
Was this page helpful?