Skip to content

Schema to JSON Schema

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

Example (Creating a JSON Schema for a Struct)

The following example defines a Person schema with properties for name (a string) and age (a number). It then generates 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.

Example (Excluding Transformations in JSON Schema)

Consider modifying the age field to include both a refinement and a transformation. Only the refinement is reflected in the JSON Schema.

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 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 from the 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
*/

In this case, the JSON Schema reflects the integer refinement but does not include the transformation that clamps the value.

Literals are transformed into enum types within JSON Schema.

Example (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
*/

Example (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
*/

Represents an array with at least one element.

Example

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
*/

Combines fixed properties from a struct with dynamic properties from a record.

Example

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:

Example (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
*/

Example (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 add identifier annotations to schemas to improve structure and maintainability. Annotated schemas are included in a $defs object in the root of the JSON Schema and referenced from there.

Example (Using Identifier Annotations)

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
5
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" })
6
7
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
({
8
(property) name: Schema.SchemaClass<string, string, never>
name
:
const Name: Schema.SchemaClass<string, string, never>
Name
,
9
(property) age: Schema.SchemaClass<number, number, never>
age
:
const Age: Schema.SchemaClass<number, number, never>
Age
10
})
11
12
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
)
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
"name",
22
"age"
23
],
24
"properties": {
25
"name": {
26
"$ref": "#/$defs/Name"
27
},
28
"age": {
29
"$ref": "#/$defs/Age"
30
}
31
},
32
"additionalProperties": false,
33
"$defs": {
34
"Name": {
35
"type": "string",
36
"description": "a string",
37
"title": "string"
38
},
39
"Age": {
40
"type": "number",
41
"description": "a number",
42
"title": "number"
43
}
44
}
45
}
46
*/

By using identifier annotations, schemas can be reused and referenced more easily, especially in complex JSON Schemas.

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.

Example (Using Annotations for Metadata)

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.

Example (Annotated Struct Properties)

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.

Example (Recursive Schema with Identifier Annotations)

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

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
// Define the interface representing a category structure
4
interface
interface Category
Category
{
5
readonly
(property) Category.name: string
name
: string
6
readonly
(property) Category.categories: readonly Category[]
categories
:
interface ReadonlyArray<T>
ReadonlyArray
<
interface Category
Category
>
7
}
8
9
// Define a recursive schema with a required identifier annotation
10
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
({
11
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
12
(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
(
13
// Recursive reference to the Category schema
14
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
)
15
)
16
}).
(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" })
17
18
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
)
19
20
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))
21
/*
22
Output:
23
{
24
"$schema": "http://json-schema.org/draft-07/schema#",
25
"$ref": "#/$defs/Category",
26
"$defs": {
27
"Category": {
28
"type": "object",
29
"required": [
30
"name",
31
"categories"
32
],
33
"properties": {
34
"name": {
35
"type": "string"
36
},
37
"categories": {
38
"type": "array",
39
"items": {
40
"$ref": "#/$defs/Category"
41
}
42
}
43
},
44
"additionalProperties": false
45
}
46
}
47
}
48
*/

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.

Example (Error Due to Missing Annotation)

Attempting to generate a JSON Schema for unsupported types like bigint will lead to a missing annotation error:

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 jsonSchema annotation, defining how you intend to represent such types in JSON Schema:

Example (Using Custom Annotation for Unsupported Type)

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
// Adding a custom JSON Schema annotation for the `bigint` type
5
(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
({
6
(property) Annotations.Schema<bigint, readonly []>.jsonSchema?: object
jsonSchema
: {
7
(property) type: string
type
: "some custom way to represent a bigint in JSON Schema"
8
}
9
})
10
})
11
12
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
)
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
"a_bigint_field"
22
],
23
"properties": {
24
"a_bigint_field": {
25
"type": "some custom way to represent a bigint in JSON Schema"
26
}
27
},
28
"additionalProperties": false
29
}
30
*/

When defining a refinement (e.g., through the Schema.filter function), you can include a JSON Schema annotation to describe the refinement. This annotation is added as a “fragment” that becomes part of the generated JSON Schema. If a schema contains multiple refinements, their respective annotations are merged into the output.

Example (Using Refinements with Merged Annotations)

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
// Define a schema with a refinement for positive numbers
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 }
7
})
8
)
9
10
// Add an upper bound refinement to the schema
11
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
(
12
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, {
13
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.jsonSchema?: object
jsonSchema
: {
(property) maximum: number
maximum
: 10 }
14
})
15
)
16
17
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
)
18
19
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))
20
/*
21
Output:
22
{
23
"$schema": "http://json-schema.org/draft-07/schema#",
24
"type": "number",
25
"minimum": 0,
26
"maximum": 10
27
}
28
*/

The jsonSchema annotation is defined as a generic object, allowing it to represent non-standard extensions. This flexibility leaves the responsibility of enforcing type constraints to 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 (Ensuring Type Correctness)

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 } // Generic object, no type enforcement
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
// Enforces type constraints
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 schema types other than refinements, you can override the default generated JSON Schema by providing a custom jsonSchema annotation. The content of this annotation will replace the system-generated schema.

Example (Custom Annotation for a Struct)

1
import {
import JSONSchema
JSONSchema
,
import Schema
Schema
} from "effect"
2
3
// Define a struct with a custom JSON Schema annotation
4
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
({
5
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.jsonSchema?: object
jsonSchema
: {
(property) type: string
type
: "object" }
6
})
7
8
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
)
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
}
17
the default would be:
18
{
19
"$schema": "http://json-schema.org/draft-07/schema#",
20
"type": "object",
21
"required": [
22
"foo"
23
],
24
"properties": {
25
"foo": {
26
"type": "string"
27
}
28
},
29
"additionalProperties": false
30
}
31
*/

The Schema.parseJson function provides a unique approach to JSON Schema generation. Instead of defaulting to a schema for a plain string, which represents the “from” side of the transformation, it generates a schema based on the structure provided within the argument.

This behavior ensures that the generated JSON Schema reflects the intended structure of the parsed data, rather than the raw JSON input.

Example (Generating JSON Schema for a Parsed Object)

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
// Nested parsing: JSON string to a number
7
(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
)
8
})
9
)
10
11
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
)
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"
21
],
22
"properties": {
23
"a": {
24
"type": "string"
25
}
26
},
27
"additionalProperties": false
28
}
29
*/