Skip to content

Effect Schema to JSON Schema

The JSONSchema.make function allows you to generate a JSON Schema from a predefined schema.

Example

Here’s an example where we define a schema for a “Person” with properties “name” (a string) and “age” (a number) and we generate the corresponding JSON Schema.

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>(fields: { name: typeof Schema.String; age: typeof Schema.Number; }): Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }> (+1 overload) namespace Struct
Struct
({
4
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
5
(property) age: typeof Schema.Number
age
:
import Schema
Schema
.
(alias) class Number export Number
Number
6
})
7
8
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>(schema: Schema.Schema<{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>) => JSONSchema.JsonSchema7Root
make
(
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
)
9
10
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
11
/*
12
Output:
13
{
14
"$schema": "http://json-schema.org/draft-07/schema#",
15
"type": "object",
16
"required": [
17
"name",
18
"age"
19
],
20
"properties": {
21
"name": {
22
"type": "string"
23
},
24
"age": {
25
"type": "number"
26
}
27
},
28
"additionalProperties": false
29
}
30
*/

The JSONSchema.make function aims to produce an optimal JSON Schema representing the input part of the decoding phase. It does this by traversing the schema from the most nested component, incorporating each refinement, and stops at the first transformation encountered.

Consider a modification to the schema of the age field:

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const Person: Schema.Struct<{ name: typeof Schema.String; age: Schema.transform<Schema.Schema<number, number, never>, Schema.filter<Schema.Schema<number, number, never>>>; }>
Person
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; age: Schema.transform<Schema.Schema<number, number, never>, Schema.filter<Schema.Schema<number, number, never>>>; }>(fields: { ...; }): Schema.Struct<...> (+1 overload) namespace Struct
Struct
({
4
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
5
(property) age: Schema.transform<Schema.Schema<number, number, never>, Schema.filter<Schema.Schema<number, number, never>>>
age
:
import Schema
Schema
.
(alias) class Number export Number
Number
.
(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>, Schema.transform<Schema.Schema<number, number, never>, Schema.filter<Schema.Schema<number, number, never>>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<...>, bc: (_: Schema.filter<...>) => Schema.transform<...>): Schema.transform<...> (+21 overloads)
pipe
(
6
// refinement, included in the generated JSON Schema
7
import Schema
Schema
.
const int: <number>(annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
int
(),
8
// transformation, excluded in the generated JSON Schema
9
import Schema
Schema
.
const clamp: (minimum: number, maximum: number) => <A extends number, I, R>(self: Schema.Schema<A, I, R>) => Schema.transform<Schema.Schema<A, I, R>, Schema.filter<Schema.Schema<A>>>

Clamps a number between a minimum and a maximum value.

clamp
(1, 10)
10
)
11
})
12
13
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>(schema: Schema.Schema<{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>) => JSONSchema.JsonSchema7Root
make
(
const Person: Schema.Struct<{ name: typeof Schema.String; age: Schema.transform<Schema.Schema<number, number, never>, Schema.filter<Schema.Schema<number, number, never>>>; }>
Person
)
14
15
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
16
/*
17
Output:
18
{
19
"$schema": "http://json-schema.org/draft-07/schema#",
20
"type": "object",
21
"required": [
22
"name",
23
"age"
24
],
25
"properties": {
26
"name": {
27
"type": "string"
28
},
29
"age": {
30
"type": "integer",
31
"description": "an integer",
32
"title": "integer"
33
}
34
},
35
"additionalProperties": false
36
}
37
*/

The new JSON Schema for the age field shows it as type "integer", keeping the refinement of being an integer and excluding the transformation that clamps the value between 1 and 10.

Literals are transformed into enum types within JSON Schema:

Single literal

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Literal<["a"]>
schema
=
import Schema
Schema
.
function Literal<["a"]>(literals_0: "a"): Schema.Literal<["a"]> (+2 overloads)
Literal
("a")
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <"a", "a", never>(schema: Schema.Schema<"a", "a", never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Literal<["a"]>
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"enum": [
11
"a"
12
]
13
}
14
*/

Union of literals

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Literal<["a", "b"]>
schema
=
import Schema
Schema
.
function Literal<["a", "b"]>(literals_0: "a", literals_1: "b"): Schema.Literal<["a", "b"]> (+2 overloads)
Literal
("a", "b")
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <"a" | "b", "a" | "b", never>(schema: Schema.Schema<"a" | "b", "a" | "b", never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Literal<["a", "b"]>
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"enum": [
11
"a",
12
"b"
13
]
14
}
15
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: typeof Schema.Void
schema
=
import Schema
Schema
.
class Void
Void
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <void, void, never>(schema: Schema.Schema<void, void, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: typeof Schema.Void
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"$id": "/schemas/void",
11
"title": "void"
12
}
13
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: typeof Schema.Any
schema
=
import Schema
Schema
.
class Any
Any
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <any, any, never>(schema: Schema.Schema<any, any, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: typeof Schema.Any
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"$id": "/schemas/any",
11
"title": "any"
12
}
13
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: typeof Schema.Unknown
schema
=
import Schema
Schema
.
class Unknown
Unknown
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <unknown, unknown, never>(schema: Schema.Schema<unknown, unknown, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: typeof Schema.Unknown
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"$id": "/schemas/unknown",
11
"title": "unknown"
12
}
13
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: typeof Schema.Object
schema
=
import Schema
Schema
.
(alias) class Object export Object
Object
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <object, object, never>(schema: Schema.Schema<object, object, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: typeof Schema.Object
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"$id": "/schemas/object",
11
"anyOf": [
12
{
13
"type": "object"
14
},
15
{
16
"type": "array"
17
}
18
],
19
"description": "an object in the TypeScript meaning, i.e. the `object` type",
20
"title": "object"
21
}
22
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: typeof Schema.String
schema
=
import Schema
Schema
.
(alias) class String export String
String
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <string, string, never>(schema: Schema.Schema<string, string, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: typeof Schema.String
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"type": "string"
11
}
12
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: typeof Schema.Number
schema
=
import Schema
Schema
.
(alias) class Number export Number
Number
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <number, number, never>(schema: Schema.Schema<number, number, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: typeof Schema.Number
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"type": "number"
11
}
12
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: typeof Schema.Boolean
schema
=
import Schema
Schema
.
(alias) class Boolean export Boolean
Boolean
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <boolean, boolean, never>(schema: Schema.Schema<boolean, boolean, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: typeof Schema.Boolean
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"type": "boolean"
11
}
12
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Tuple<[typeof Schema.String, typeof Schema.Number]>
schema
=
import Schema
Schema
.
function Tuple<[typeof Schema.String, typeof Schema.Number]>(elements_0: typeof Schema.String, elements_1: typeof Schema.Number): Schema.Tuple<[typeof Schema.String, typeof Schema.Number]> (+1 overload)
Tuple
(
import Schema
Schema
.
(alias) class String export String
String
,
import Schema
Schema
.
(alias) class Number export Number
Number
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <readonly [string, number], readonly [string, number], never>(schema: Schema.Schema<readonly [string, number], readonly [string, number], never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Tuple<[typeof Schema.String, typeof Schema.Number]>
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"type": "array",
11
"minItems": 2,
12
"items": [
13
{
14
"type": "string"
15
},
16
{
17
"type": "number"
18
}
19
],
20
"additionalItems": false
21
}
22
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Array$<typeof Schema.String>
schema
=
import Schema
Schema
.
(alias) Array<typeof Schema.String>(value: typeof Schema.String): Schema.Array$<typeof Schema.String> export Array
Array
(
import Schema
Schema
.
(alias) class String export String
String
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <readonly string[], readonly string[], never>(schema: Schema.Schema<readonly string[], readonly string[], never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Array$<typeof Schema.String>
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"type": "array",
11
"items": {
12
"type": "string"
13
}
14
}
15
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.NonEmptyArray<typeof Schema.String>
schema
=
import Schema
Schema
.
const NonEmptyArray: <typeof Schema.String>(value: typeof Schema.String) => Schema.NonEmptyArray<typeof Schema.String>
NonEmptyArray
(
import Schema
Schema
.
(alias) class String export String
String
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <readonly [string, ...string[]], readonly [string, ...string[]], never>(schema: Schema.Schema<readonly [string, ...string[]], readonly [string, ...string[]], never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.NonEmptyArray<typeof Schema.String>
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"type": "array",
11
"minItems": 1,
12
"items": {
13
"type": "string"
14
}
15
}
16
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
schema
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>(fields: { name: typeof Schema.String; age: typeof Schema.Number; }): Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }> (+1 overload) namespace Struct
Struct
({
4
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
5
(property) age: typeof Schema.Number
age
:
import Schema
Schema
.
(alias) class Number export Number
Number
6
})
7
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>(schema: Schema.Schema<{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
schema
), null, 2))
9
/*
10
Output:
11
{
12
"$schema": "http://json-schema.org/draft-07/schema#",
13
"type": "object",
14
"required": [
15
"name",
16
"age"
17
],
18
"properties": {
19
"name": {
20
"type": "string"
21
},
22
"age": {
23
"type": "number"
24
}
25
},
26
"additionalProperties": false
27
}
28
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Record$<typeof Schema.String, typeof Schema.Number>
schema
=
import Schema
Schema
.
const Record: <typeof Schema.String, typeof Schema.Number>(options: { readonly key: typeof Schema.String; readonly value: typeof Schema.Number; }) => Schema.Record$<typeof Schema.String, typeof Schema.Number>
Record
({
4
(property) key: typeof Schema.String
key
:
import Schema
Schema
.
(alias) class String export String
String
,
5
(property) value: typeof Schema.Number
value
:
import Schema
Schema
.
(alias) class Number export Number
Number
6
})
7
8
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <{ readonly [x: string]: number; }, { readonly [x: string]: number; }, never>(schema: Schema.Schema<{ readonly [x: string]: number; }, { readonly [x: string]: number; }, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Record$<typeof Schema.String, typeof Schema.Number>
schema
), null, 2))
9
/*
10
Output:
11
{
12
"$schema": "http://json-schema.org/draft-07/schema#",
13
"type": "object",
14
"required": [],
15
"properties": {},
16
"patternProperties": {
17
"": {
18
"type": "number"
19
}
20
}
21
}
22
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.TypeLiteral<{ name: typeof Schema.String; age: typeof Schema.Number; }, readonly [Schema.Record$<typeof Schema.String, Schema.Union<[typeof Schema.String, typeof Schema.Number]>>]>
schema
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }, readonly [Schema.Record$<typeof Schema.String, Schema.Union<[typeof Schema.String, typeof Schema.Number]>>]>(fields: { ...; }, records_0: Schema.Record$<...>): Schema.TypeLiteral<...> (+1 overload) namespace Struct
Struct
(
4
{
5
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
6
(property) age: typeof Schema.Number
age
:
import Schema
Schema
.
(alias) class Number export Number
Number
7
},
8
import Schema
Schema
.
const Record: <typeof Schema.String, Schema.Union<[typeof Schema.String, typeof Schema.Number]>>(options: { readonly key: typeof Schema.String; readonly value: Schema.Union<[typeof Schema.String, typeof Schema.Number]>; }) => Schema.Record$<...>
Record
({
9
(property) key: typeof Schema.String
key
:
import Schema
Schema
.
(alias) class String export String
String
,
10
(property) value: Schema.Union<[typeof Schema.String, typeof Schema.Number]>
value
:
import Schema
Schema
.
function Union<[typeof Schema.String, typeof Schema.Number]>(members_0: typeof Schema.String, members_1: typeof Schema.Number): Schema.Union<[typeof Schema.String, typeof Schema.Number]> (+3 overloads)
Union
(
import Schema
Schema
.
(alias) class String export String
String
,
import Schema
Schema
.
(alias) class Number export Number
Number
)
11
})
12
)
13
14
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <{ readonly [x: string]: string | number; readonly name: string; readonly age: number; }, { readonly [x: string]: string | number; readonly name: string; readonly age: number; }, never>(schema: Schema.Schema<{ readonly [x: string]: string | number; readonly name: string; readonly age: number; }, { ...; }, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.TypeLiteral<{ name: typeof Schema.String; age: typeof Schema.Number; }, readonly [Schema.Record$<typeof Schema.String, Schema.Union<[typeof Schema.String, typeof Schema.Number]>>]>
schema
), null, 2))
15
/*
16
Output:
17
{
18
"$schema": "http://json-schema.org/draft-07/schema#",
19
"type": "object",
20
"required": [
21
"name",
22
"age"
23
],
24
"properties": {
25
"name": {
26
"type": "string"
27
},
28
"age": {
29
"type": "number"
30
}
31
},
32
"patternProperties": {
33
"": {
34
"anyOf": [
35
{
36
"type": "string"
37
},
38
{
39
"type": "number"
40
}
41
]
42
}
43
}
44
}
45
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
enum
enum Fruits
Fruits
{
4
(enum member) Fruits.Apple = 0
Apple
,
5
(enum member) Fruits.Banana = 1
Banana
6
}
7
8
const
const schema: Schema.Enums<typeof Fruits>
schema
=
import Schema
Schema
.
const Enums: <typeof Fruits>(enums: typeof Fruits) => Schema.Enums<typeof Fruits>
Enums
(
enum Fruits
Fruits
)
9
10
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <Fruits, Fruits, never>(schema: Schema.Schema<Fruits, Fruits, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Enums<typeof Fruits>
schema
), null, 2))
11
/*
12
Output:
13
{
14
"$schema": "http://json-schema.org/draft-07/schema#",
15
"$comment": "/schemas/enums",
16
"anyOf": [
17
{
18
"title": "Apple",
19
"enum": [
20
0
21
]
22
},
23
{
24
"title": "Banana",
25
"enum": [
26
1
27
]
28
}
29
]
30
}
31
*/
1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.TemplateLiteral<`a${number}`>
schema
=
import Schema
Schema
.
const TemplateLiteral: <[Schema.Literal<["a"]>, typeof Schema.Number]>(head: Schema.Literal<["a"]>, tail_0: typeof Schema.Number) => Schema.TemplateLiteral<`a${number}`>
TemplateLiteral
(
import Schema
Schema
.
function Literal<["a"]>(literals_0: "a"): Schema.Literal<["a"]> (+2 overloads)
Literal
("a"),
import Schema
Schema
.
(alias) class Number export Number
Number
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <`a${number}`, `a${number}`, never>(schema: Schema.Schema<`a${number}`, `a${number}`, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.TemplateLiteral<`a${number}`>
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"type": "string",
11
"description": "a template literal",
12
"pattern": "^a[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?$"
13
}
14
*/

Unions are expressed using anyOf or enum, depending on the types involved:

Generic Union

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Union<[typeof Schema.String, typeof Schema.Number]>
schema
=
import Schema
Schema
.
function Union<[typeof Schema.String, typeof Schema.Number]>(members_0: typeof Schema.String, members_1: typeof Schema.Number): Schema.Union<[typeof Schema.String, typeof Schema.Number]> (+3 overloads)
Union
(
import Schema
Schema
.
(alias) class String export String
String
,
import Schema
Schema
.
(alias) class Number export Number
Number
)
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <string | number, string | number, never>(schema: Schema.Schema<string | number, string | number, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Union<[typeof Schema.String, typeof Schema.Number]>
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"anyOf": [
11
{
12
"type": "string"
13
},
14
{
15
"type": "number"
16
}
17
]
18
}
19
*/

Union of literals

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Literal<["a", "b"]>
schema
=
import Schema
Schema
.
function Literal<["a", "b"]>(literals_0: "a", literals_1: "b"): Schema.Literal<["a", "b"]> (+2 overloads)
Literal
("a", "b")
4
5
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
import JSONSchema
JSONSchema
.
const make: <"a" | "b", "a" | "b", never>(schema: Schema.Schema<"a" | "b", "a" | "b", never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Literal<["a", "b"]>
schema
), null, 2))
6
/*
7
Output:
8
{
9
"$schema": "http://json-schema.org/draft-07/schema#",
10
"enum": [
11
"a",
12
"b"
13
]
14
}
15
*/

You can augment your schemas with identifier annotations to enhance their structure and maintainability. When you utilize these annotations, your schemas are included within a “$defs” object property at the root of the JSON Schema and referenced from there, enabling better organization and readability.

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const Name: Schema.SchemaClass<string, string, never>
Name
=
import Schema
Schema
.
(alias) class String export String
String
.
(method) Annotable<SchemaClass<string, string, never>, string, string, never>.annotations(annotations: Schema.Annotations.Schema<string, readonly []>): Schema.SchemaClass<string, string, never>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
(property) Annotations.Schema<string, readonly []>.identifier?: string
identifier
: "Name" })
4
const
const Age: Schema.SchemaClass<number, number, never>
Age
=
import Schema
Schema
.
(alias) class Number export Number
Number
.
(method) Annotable<SchemaClass<number, number, never>, number, number, never>.annotations(annotations: Schema.Annotations.Schema<number, readonly []>): Schema.SchemaClass<number, number, never>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.identifier?: string
identifier
: "Age" })
5
const
const Person: Schema.Struct<{ name: Schema.SchemaClass<string, string, never>; age: Schema.SchemaClass<number, number, never>; }>
Person
=
import Schema
Schema
.
function Struct<{ name: Schema.SchemaClass<string, string, never>; age: Schema.SchemaClass<number, number, never>; }>(fields: { name: Schema.SchemaClass<string, string, never>; age: Schema.SchemaClass<...>; }): Schema.Struct<...> (+1 overload) namespace Struct
Struct
({
6
(property) name: Schema.SchemaClass<string, string, never>
name
:
const Name: Schema.SchemaClass<string, string, never>
Name
,
7
(property) age: Schema.SchemaClass<number, number, never>
age
:
const Age: Schema.SchemaClass<number, number, never>
Age
8
})
9
10
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>(schema: Schema.Schema<{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>) => JSONSchema.JsonSchema7Root
make
(
const Person: Schema.Struct<{ name: Schema.SchemaClass<string, string, never>; age: Schema.SchemaClass<number, number, never>; }>
Person
)
11
12
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
13
/*
14
Output:
15
{
16
"$schema": "http://json-schema.org/draft-07/schema#",
17
"type": "object",
18
"required": [
19
"name",
20
"age"
21
],
22
"properties": {
23
"name": {
24
"$ref": "#/$defs/Name"
25
},
26
"age": {
27
"$ref": "#/$defs/Age"
28
}
29
},
30
"additionalProperties": false,
31
"$defs": {
32
"Name": {
33
"type": "string",
34
"description": "a string",
35
"title": "string"
36
},
37
"Age": {
38
"type": "number",
39
"description": "a number",
40
"title": "number"
41
}
42
}
43
}
44
*/

By structuring your JSON Schema with identifier annotations, each annotated schema is clearly defined in a separate section, making the entire schema easier to navigate and maintain. This approach is especially useful for complex schemas that require clear documentation of each component.

Standard JSON Schema annotations such as title, description, default, and examples are supported. These annotations allow you to enrich your schemas with metadata that can enhance readability and provide additional information about the data structure.

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.SchemaClass<string, string, never>
schema
=
import Schema
Schema
.
(alias) class String export String
String
.
(method) Annotable<SchemaClass<string, string, never>, string, string, never>.annotations(annotations: Schema.Annotations.Schema<string, readonly []>): Schema.SchemaClass<string, string, never>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
4
(property) Annotations.Doc<string>.description?: string
description
: "my custom description",
5
(property) Annotations.Doc<string>.title?: string
title
: "my custom title",
6
(property) Annotations.Doc<string>.default?: string
default
: "",
7
(property) Annotations.Doc<string>.examples?: readonly [string, ...string[]]
examples
: ["a", "b"]
8
})
9
10
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <string, string, never>(schema: Schema.Schema<string, string, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.SchemaClass<string, string, never>
schema
)
11
12
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
13
/*
14
Output:
15
{
16
"$schema": "http://json-schema.org/draft-07/schema#",
17
"type": "string",
18
"description": "my custom description",
19
"title": "my custom title",
20
"examples": [
21
"a",
22
"b"
23
],
24
"default": ""
25
}
26
*/

To enhance the clarity of your JSON schemas, it’s advisable to add annotations directly to the property signatures rather than to the type itself. This method is more semantically appropriate as it links descriptive titles and other metadata specifically to the properties they describe, rather than to the generic type.

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const Person: Schema.Struct<{ firstName: Schema.propertySignature<typeof Schema.String>; lastName: Schema.propertySignature<typeof Schema.String>; }>
Person
=
import Schema
Schema
.
function Struct<{ firstName: Schema.propertySignature<typeof Schema.String>; lastName: Schema.propertySignature<typeof Schema.String>; }>(fields: { firstName: Schema.propertySignature<typeof Schema.String>; lastName: Schema.propertySignature<...>; }): Schema.Struct<...> (+1 overload) namespace Struct
Struct
({
4
(property) firstName: Schema.propertySignature<typeof Schema.String>
firstName
:
import Schema
Schema
.
const propertySignature: <typeof Schema.String>(self: typeof Schema.String) => Schema.propertySignature<typeof Schema.String>

Lifts a `Schema` into a `PropertySignature`.

propertySignature
(
import Schema
Schema
.
(alias) class String export String
String
).
(method) propertySignature<typeof String$>.annotations(annotations: Schema.PropertySignature<TypeToken extends Schema.PropertySignature.Token, Type, Key extends PropertyKey, EncodedToken extends Schema.PropertySignature.Token, Encoded, HasDefault extends boolean = false, R = never>.Annotations<string>): Schema.propertySignature<...>
annotations
({
5
(property) Annotations.Doc<string>.title?: string
title
: "First name"
6
}),
7
(property) lastName: Schema.propertySignature<typeof Schema.String>
lastName
:
import Schema
Schema
.
const propertySignature: <typeof Schema.String>(self: typeof Schema.String) => Schema.propertySignature<typeof Schema.String>

Lifts a `Schema` into a `PropertySignature`.

propertySignature
(
import Schema
Schema
.
(alias) class String export String
String
).
(method) propertySignature<typeof String$>.annotations(annotations: Schema.PropertySignature<TypeToken extends Schema.PropertySignature.Token, Type, Key extends PropertyKey, EncodedToken extends Schema.PropertySignature.Token, Encoded, HasDefault extends boolean = false, R = never>.Annotations<string>): Schema.propertySignature<...>
annotations
({
8
(property) Annotations.Doc<string>.title?: string
title
: "Last Name"
9
})
10
})
11
12
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <{ readonly firstName: string; readonly lastName: string; }, { readonly firstName: string; readonly lastName: string; }, never>(schema: Schema.Schema<{ readonly firstName: string; readonly lastName: string; }, { ...; }, never>) => JSONSchema.JsonSchema7Root
make
(
const Person: Schema.Struct<{ firstName: Schema.propertySignature<typeof Schema.String>; lastName: Schema.propertySignature<typeof Schema.String>; }>
Person
)
13
14
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
15
/*
16
Output:
17
{
18
"$schema": "http://json-schema.org/draft-07/schema#",
19
"type": "object",
20
"required": [
21
"firstName",
22
"lastName"
23
],
24
"properties": {
25
"firstName": {
26
"type": "string",
27
"title": "First name"
28
},
29
"lastName": {
30
"type": "string",
31
"title": "Last Name"
32
}
33
},
34
"additionalProperties": false
35
}
36
*/

Recursive and mutually recursive schemas are supported, however it’s mandatory to use identifier annotations for these types of schemas to ensure correct references and definitions within the generated JSON Schema.

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
interface
interface Category
Category
{
4
readonly
(property) Category.name: string
name
: string
5
readonly
(property) Category.categories: readonly Category[]
categories
:
interface ReadonlyArray<T>
ReadonlyArray
<
interface Category
Category
>
6
}
7
8
// Define a recursive schema with a required identifier annotation
9
const
const Category: Schema.Struct<{ name: typeof Schema.String; categories: Schema.Array$<Schema.suspend<Category, Category, never>>; }>
Category
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; categories: Schema.Array$<Schema.suspend<Category, Category, never>>; }>(fields: { name: typeof Schema.String; categories: Schema.Array$<...>; }): Schema.Struct<...> (+1 overload) namespace Struct
Struct
({
10
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
11
(property) categories: Schema.Array$<Schema.suspend<Category, Category, never>>
categories
:
import Schema
Schema
.
(alias) Array<Schema.suspend<Category, Category, never>>(value: Schema.suspend<Category, Category, never>): Schema.Array$<Schema.suspend<Category, Category, never>> export Array
Array
(
12
import Schema
Schema
.
const suspend: <Category, Category, never>(f: () => Schema.Schema<Category, Category, never>) => Schema.suspend<Category, Category, never>
suspend
(():
import Schema
Schema
.
interface Schema<in out A, in out I = A, out R = never> namespace Schema
Schema
<
interface Category
Category
> =>
const Category: Schema.Struct<{ name: typeof Schema.String; categories: Schema.Array$<Schema.suspend<Category, Category, never>>; }>
Category
)
13
)
14
}).
(method) Struct<{ name: typeof String$; categories: Array$<suspend<Category, Category, never>>; }>.annotations(annotations: Schema.Annotations.Schema<{ readonly name: string; readonly categories: readonly Category[]; }, readonly []>): Schema.Struct<{ name: typeof Schema.String; categories: Schema.Array$<Schema.suspend<Category, Category, never>>; }>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.identifier?: string
identifier
: "Category" })
15
16
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <{ readonly name: string; readonly categories: readonly Category[]; }, { readonly name: string; readonly categories: readonly Category[]; }, never>(schema: Schema.Schema<{ readonly name: string; readonly categories: readonly Category[]; }, { ...; }, never>) => JSONSchema.JsonSchema7Root
make
(
const Category: Schema.Struct<{ name: typeof Schema.String; categories: Schema.Array$<Schema.suspend<Category, Category, never>>; }>
Category
)
17
18
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
19
/*
20
Output:
21
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
23
"$ref": "#/$defs/Category",
24
"$defs": {
25
"Category": {
26
"type": "object",
27
"required": [
28
"name",
29
"categories"
30
],
31
"properties": {
32
"name": {
33
"type": "string"
34
},
35
"categories": {
36
"type": "array",
37
"items": {
38
"$ref": "#/$defs/Category"
39
}
40
}
41
},
42
"additionalProperties": false
43
}
44
}
45
}
46
*/

In this example, the Category schema refers to itself, making it necessary to use an identifier annotation to facilitate the reference.

When working with JSON Schema certain data types, such as bigint, lack a direct representation because JSON Schema does not natively support them. This absence typically leads to an error when the schema is generated:

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Struct<{ a_bigint_field: typeof Schema.BigIntFromSelf; }>
schema
=
import Schema
Schema
.
function Struct<{ a_bigint_field: typeof Schema.BigIntFromSelf; }>(fields: { a_bigint_field: typeof Schema.BigIntFromSelf; }): Schema.Struct<{ a_bigint_field: typeof Schema.BigIntFromSelf; }> (+1 overload) namespace Struct
Struct
({
4
(property) a_bigint_field: typeof Schema.BigIntFromSelf
a_bigint_field
:
import Schema
Schema
.
class BigIntFromSelf
BigIntFromSelf
5
})
6
7
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <{ readonly a_bigint_field: bigint; }, { readonly a_bigint_field: bigint; }, never>(schema: Schema.Schema<{ readonly a_bigint_field: bigint; }, { readonly a_bigint_field: bigint; }, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Struct<{ a_bigint_field: typeof Schema.BigIntFromSelf; }>
schema
)
8
9
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
10
/*
11
throws:
12
Error: Missing annotation
13
at path: ["a_bigint_field"]
14
details: Generating a JSON Schema for this schema requires a "jsonSchema" annotation
15
schema (BigIntKeyword): bigint
16
*/

To address this, you can enhance the schema with a custom annotation, defining how you intend to represent such types in JSON Schema:

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Struct<{ a_bigint_field: Schema.SchemaClass<bigint, bigint, never>; }>
schema
=
import Schema
Schema
.
function Struct<{ a_bigint_field: Schema.SchemaClass<bigint, bigint, never>; }>(fields: { a_bigint_field: Schema.SchemaClass<bigint, bigint, never>; }): Schema.Struct<{ a_bigint_field: Schema.SchemaClass<bigint, bigint, never>; }> (+1 overload) namespace Struct
Struct
({
4
(property) a_bigint_field: Schema.SchemaClass<bigint, bigint, never>
a_bigint_field
:
import Schema
Schema
.
class BigIntFromSelf
BigIntFromSelf
.
(method) Annotable<SchemaClass<bigint, bigint, never>, bigint, bigint, never>.annotations(annotations: Schema.Annotations.Schema<bigint, readonly []>): Schema.SchemaClass<bigint, bigint, never>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
5
(property) Annotations.Schema<bigint, readonly []>.jsonSchema?: object
jsonSchema
: {
6
(property) type: string
type
: "some custom way to represent a bigint in JSON Schema"
7
}
8
})
9
})
10
11
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <{ readonly a_bigint_field: bigint; }, { readonly a_bigint_field: bigint; }, never>(schema: Schema.Schema<{ readonly a_bigint_field: bigint; }, { readonly a_bigint_field: bigint; }, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Struct<{ a_bigint_field: Schema.SchemaClass<bigint, bigint, never>; }>
schema
)
12
13
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
14
/*
15
Output:
16
{
17
"$schema": "http://json-schema.org/draft-07/schema#",
18
"type": "object",
19
"required": [
20
"a_bigint_field"
21
],
22
"properties": {
23
"a_bigint_field": {
24
"type": "some custom way to represent a bigint in JSON Schema"
25
}
26
},
27
"additionalProperties": false
28
}
29
*/

When defining a refinement (e.g., through the filter function), you can attach a JSON Schema annotation to your schema containing a JSON Schema “fragment” related to this particular refinement. This fragment will be used to generate the corresponding JSON Schema. Note that if the schema consists of more than one refinement, the corresponding annotations will be merged.

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const Positive: Schema.filter<typeof Schema.Number>
Positive
=
import Schema
Schema
.
(alias) class Number export Number
Number
.
(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<typeof Schema.Number>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<typeof Schema.Number>): Schema.filter<...> (+21 overloads)
pipe
(
4
import Schema
Schema
.
function filter<typeof Schema.Number>(predicate: (a: number, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: typeof Schema.Number) => Schema.filter<...> (+2 overloads)
filter
((
(parameter) n: number
n
) =>
(parameter) n: number
n
> 0, {
5
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.jsonSchema?: object
jsonSchema
: {
(property) minimum: number
minimum
: 0 }
6
})
7
)
8
9
const
const schema: Schema.filter<Schema.filter<typeof Schema.Number>>
schema
=
const Positive: Schema.filter<typeof Schema.Number>
Positive
.
(method) Pipeable.pipe<Schema.filter<typeof Schema.Number>, Schema.filter<Schema.filter<typeof Schema.Number>>>(this: Schema.filter<...>, ab: (_: Schema.filter<typeof Schema.Number>) => Schema.filter<...>): Schema.filter<...> (+21 overloads)
pipe
(
10
import Schema
Schema
.
function filter<Schema.filter<typeof Schema.Number>>(predicate: (a: number, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: Schema.filter<...>) => Schema.filter<...> (+2 overloads)
filter
((
(parameter) n: number
n
) =>
(parameter) n: number
n
<= 10, {
11
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.jsonSchema?: object
jsonSchema
: {
(property) maximum: number
maximum
: 10 }
12
})
13
)
14
15
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <number, number, never>(schema: Schema.Schema<number, number, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.filter<Schema.filter<typeof Schema.Number>>
schema
)
16
17
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
18
/*
19
Output:
20
{
21
"$schema": "http://json-schema.org/draft-07/schema#",
22
"type": "number",
23
"minimum": 0,
24
"maximum": 10
25
}
26
*/

The jsonSchema annotation is intentionally defined as a generic object. This allows it to describe non-standard extensions. As a result, the responsibility of enforcing type constraints is left to you, the user.

If you prefer stricter type enforcement or need to support non-standard extensions, you can introduce a satisfies constraint on the object literal. This constraint should be used in conjunction with the typing library of your choice.

Example

In the following example, we’ve used the @types/json-schema package to provide TypeScript definitions for JSON Schema. This approach not only ensures type correctness but also enables autocomplete suggestions in your IDE.

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
import type {
(alias) interface JSONSchema7 import JSONSchema7
JSONSchema7
} from "json-schema"
3
4
const
const Positive: Schema.filter<typeof Schema.Number>
Positive
=
import Schema
Schema
.
(alias) class Number export Number
Number
.
(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<typeof Schema.Number>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<typeof Schema.Number>): Schema.filter<...> (+21 overloads)
pipe
(
5
import Schema
Schema
.
function filter<typeof Schema.Number>(predicate: (a: number, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: typeof Schema.Number) => Schema.filter<...> (+2 overloads)
filter
((
(parameter) n: number
n
) =>
(parameter) n: number
n
> 0, {
6
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.jsonSchema?: object
jsonSchema
: {
(property) minimum: number
minimum
: 0 } // `jsonSchema` is a generic object; you can add any key-value pair without type errors or autocomplete suggestions.
7
})
8
)
9
10
const
const schema: Schema.filter<Schema.filter<typeof Schema.Number>>
schema
=
const Positive: Schema.filter<typeof Schema.Number>
Positive
.
(method) Pipeable.pipe<Schema.filter<typeof Schema.Number>, Schema.filter<Schema.filter<typeof Schema.Number>>>(this: Schema.filter<...>, ab: (_: Schema.filter<typeof Schema.Number>) => Schema.filter<...>): Schema.filter<...> (+21 overloads)
pipe
(
11
import Schema
Schema
.
function filter<Schema.filter<typeof Schema.Number>>(predicate: (a: number, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: Schema.filter<...>) => Schema.filter<...> (+2 overloads)
filter
((
(parameter) n: number
n
) =>
(parameter) n: number
n
<= 10, {
12
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.jsonSchema?: object
jsonSchema
: {
(property) JSONSchema7.maximum?: number | undefined
maximum
: 10 } satisfies
(alias) interface JSONSchema7 import JSONSchema7
JSONSchema7
// Now `jsonSchema` is constrained to fulfill the JSONSchema7 type; incorrect properties will trigger type errors, and you'll get autocomplete suggestions.
13
})
14
)
15
16
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <number, number, never>(schema: Schema.Schema<number, number, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.filter<Schema.filter<typeof Schema.Number>>
schema
)
17
18
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
19
/*
20
Output:
21
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
23
"type": "number",
24
"minimum": 0,
25
"maximum": 10
26
}
27
*/

For all other types of schema that are not refinements, the content of the annotation is used and overrides anything the system would have generated by default:

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
const
const schema: Schema.Struct<{ foo: typeof Schema.String; }>
schema
=
import Schema
Schema
.
function Struct<{ foo: typeof Schema.String; }>(fields: { foo: typeof Schema.String; }): Schema.Struct<{ foo: typeof Schema.String; }> (+1 overload) namespace Struct
Struct
({
(property) foo: typeof Schema.String
foo
:
import Schema
Schema
.
(alias) class String export String
String
}).
(method) Struct<{ foo: typeof String$; }>.annotations(annotations: Schema.Annotations.Schema<{ readonly foo: string; }, readonly []>): Schema.Struct<{ foo: typeof Schema.String; }>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
4
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.jsonSchema?: object
jsonSchema
: {
(property) type: string
type
: "object" }
5
})
6
7
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <{ readonly foo: string; }, { readonly foo: string; }, never>(schema: Schema.Schema<{ readonly foo: string; }, { readonly foo: string; }, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.Struct<{ foo: typeof Schema.String; }>
schema
)
8
9
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
10
/*
11
Output
12
{
13
"$schema": "http://json-schema.org/draft-07/schema#",
14
"type": "object"
15
}
16
the default would be:
17
{
18
"$schema": "http://json-schema.org/draft-07/schema#",
19
"type": "object",
20
"required": [
21
"foo"
22
],
23
"properties": {
24
"foo": {
25
"type": "string"
26
}
27
},
28
"additionalProperties": false
29
}
30
*/

When utilizing Schema.parseJson, JSON Schema generation follows a specialized approach. Instead of merely generating a JSON Schema for a string—which would be the default output representing the “from” side of the transformation defined by Schema.parseJson—it specifically generates the JSON Schema for the actual schema provided as an argument.

Example

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
// Define a schema that parses a JSON string into a structured object
4
const
const schema: Schema.SchemaClass<{ readonly a: number; }, string, never>
schema
=
import Schema
Schema
.
const parseJson: <{ readonly a: number; }, { readonly a: string; }, never>(schema: Schema.Schema<{ readonly a: number; }, { readonly a: string; }, never>, options?: Schema.ParseJsonOptions) => Schema.SchemaClass<...> (+1 overload)

The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying functionality of `JSON.parse`. It also utilizes `JSON.stringify` for encoding. You can optionally provide a `ParseJsonOptions` to configure both `JSON.parse` and `JSON.stringify` executions. Optionally, you can pass a schema `Schema<A, I, R>` to obtain an `A` type instead of `unknown`.

parseJson
(
5
import Schema
Schema
.
function Struct<{ a: Schema.SchemaClass<number, string, never>; }>(fields: { a: Schema.SchemaClass<number, string, never>; }): Schema.Struct<{ a: Schema.SchemaClass<number, string, never>; }> (+1 overload) namespace Struct
Struct
({
6
(property) a: Schema.SchemaClass<number, string, never>
a
:
import Schema
Schema
.
const parseJson: <number, string, never>(schema: Schema.Schema<number, string, never>, options?: Schema.ParseJsonOptions) => Schema.SchemaClass<number, string, never> (+1 overload)

The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying functionality of `JSON.parse`. It also utilizes `JSON.stringify` for encoding. You can optionally provide a `ParseJsonOptions` to configure both `JSON.parse` and `JSON.stringify` executions. Optionally, you can pass a schema `Schema<A, I, R>` to obtain an `A` type instead of `unknown`.

parseJson
(
import Schema
Schema
.
class NumberFromString

This schema transforms a `string` into a `number` by parsing the string using the `parse` function of the `effect/Number` module. It returns an error if the value can't be converted (for example when non-numeric characters are provided). The following special string values are supported: "NaN", "Infinity", "-Infinity".

NumberFromString
) // Nested parsing from JSON string to number
7
})
8
)
9
10
const
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
=
import JSONSchema
JSONSchema
.
const make: <{ readonly a: number; }, string, never>(schema: Schema.Schema<{ readonly a: number; }, string, never>) => JSONSchema.JsonSchema7Root
make
(
const schema: Schema.SchemaClass<{ readonly a: number; }, string, never>
schema
)
11
12
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.log(message?: any, ...optionalParams: any[]): void

Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

stringify
(
const jsonSchema: JSONSchema.JsonSchema7Root
jsonSchema
, null, 2))
13
/*
14
Output:
15
{
16
"$schema": "http://json-schema.org/draft-07/schema#",
17
"type": "object",
18
"required": [
19
"a"
20
],
21
"properties": {
22
"a": {
23
"type": "string"
24
}
25
},
26
"additionalProperties": false
27
}
28
*/