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

Function declare

packages/effect/src/Schema.ts:555–567  ·  view source on GitHub ↗
(
  is: (u: unknown) => u is T,
  annotations?: Annotations.Declaration<T> | undefined
)

Source from the content-addressed store, hash-verified

553 * @since 3.10.0
554 */
555export function declare<T, Iso = T>(
556 is: (u: unknown) => u is T,
557 annotations?: Annotations.Declaration<T> | undefined
558): declare<T, Iso> {
559 return declareConstructor<T, T, Iso>()(
560 [],
561 () => (input, ast, options) =>
562 is(input) ?
563 Effect.succeed(input) :
564 Effect.fail(new SchemaIssue.InvalidType(ast, input, options)),
565 annotations
566 )
567}
568
569/**
570 * Returns a schema widened to the fully-parameterized {@link Bottom} interface,

Callers 2

instanceOfFunction · 0.70
Schema.tsFile · 0.70

Calls 4

declareConstructorFunction · 0.70
isFunction · 0.70
succeedMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected