MCPcopy Index your code
hub / github.com/Effect-TS/effect / makeTypeLiteralClass

Function makeTypeLiteralClass

packages/effect/src/Schema.ts:2866–2905  ·  view source on GitHub ↗
(
  fields: Fields,
  records: Records,
  ast: AST.AST = getDefaultTypeLiteralAST(fields, records)
)

Source from the content-addressed store, hash-verified

2864}
2865
2866function makeTypeLiteralClass<Fields extends Struct.Fields, const Records extends IndexSignature.Records>(
2867 fields: Fields,
2868 records: Records,
2869 ast: AST.AST = getDefaultTypeLiteralAST(fields, records)
2870): TypeLiteral<Fields, Records> {
2871 return class TypeLiteralClass extends make<
2872 Simplify<TypeLiteral.Type<Fields, Records>>,
2873 Simplify<TypeLiteral.Encoded<Fields, Records>>,
2874 | Struct.Context<Fields>
2875 | IndexSignature.Context<Records>
2876 >(ast) {
2877 static override annotations(
2878 annotations: Annotations.Schema<Simplify<TypeLiteral.Type<Fields, Records>>>
2879 ): TypeLiteral<Fields, Records> {
2880 return makeTypeLiteralClass(this.fields, this.records, mergeSchemaAnnotations(this.ast, annotations))
2881 }
2882
2883 static fields = { ...fields }
2884
2885 static records = [...records] as Records
2886
2887 static make = (
2888 props: Simplify<TypeLiteral.Constructor<Fields, Records>>,
2889 options?: MakeOptions
2890 ): Simplify<TypeLiteral.Type<Fields, Records>> => {
2891 const propsWithDefaults: any = lazilyMergeDefaults(fields, { ...props as any })
2892 return getDisableValidationMakeOption(options)
2893 ? propsWithDefaults
2894 : ParseResult.validateSync(this)(propsWithDefaults)
2895 }
2896
2897 static pick(...keys: Array<keyof Fields>): Struct<Simplify<Pick<Fields, typeof keys[number]>>> {
2898 return Struct(struct_.pick(fields, ...keys) as any)
2899 }
2900
2901 static omit(...keys: Array<keyof Fields>): Struct<Simplify<Omit<Fields, typeof keys[number]>>> {
2902 return Struct(struct_.omit(fields, ...keys) as any)
2903 }
2904 }
2905}
2906
2907/**
2908 * @category api interface

Callers 3

annotationsMethod · 0.85
StructFunction · 0.85
RecordClassClass · 0.85

Calls 1

getDefaultTypeLiteralASTFunction · 0.85

Tested by

no test coverage detected