MCPcopy Create free account
hub / github.com/Effect-TS/effect / declareConstructor

Function declareConstructor

packages/effect/src/Schema.ts:489–511  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

487 * @since 4.0.0
488 */
489export function declareConstructor<T, E = T, Iso = T>() {
490 return <const TypeParameters extends ReadonlyArray<Constraint>>(
491 typeParameters: TypeParameters,
492 run: (
493 typeParameters: {
494 readonly [K in keyof TypeParameters]: Codec<TypeParameters[K]["Type"], TypeParameters[K]["Encoded"]>
495 }
496 ) => (
497 u: unknown,
498 self: SchemaAST.Declaration,
499 options: SchemaAST.ParseOptions
500 ) => Effect.Effect<T, SchemaIssue.Issue>,
501 annotations?: Annotations.Declaration<T, TypeParameters>
502 ): declareConstructor<T, E, TypeParameters, Iso> => {
503 return make(
504 new SchemaAST.Declaration(
505 typeParameters.map(SchemaAST.getAST),
506 (typeParameters) => run(typeParameters.map((ast) => make(ast)) as any),
507 annotations
508 )
509 )
510 }
511}
512
513/**
514 * Type-level representation returned by {@link declare}.

Callers 12

declareFunction · 0.70
OptionFunction · 0.70
ResultFunction · 0.70
RedactedFunction · 0.70
CauseReasonFunction · 0.70
CauseFunction · 0.70
ExitFunction · 0.70
ReadonlyMapFunction · 0.70
HashMapFunction · 0.70
ReadonlySetFunction · 0.70
HashSetFunction · 0.70
ChunkFunction · 0.70

Calls 3

makeFunction · 0.70
runFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected