Wrap<A>Utility type that recursively replaces primitives with Config in a nested
structure.
When to use
Use when typing the input of unwrap so callers can pass either a Config
or a record of Configs.
Details
Config.Wrap<{ key: string }> becomes { key: Config<string> } | Config<{ key: string }>
export type type Wrap<A> = [NonNullable<A>] extends [
infer T
]
? [IsPlainObject<T>] extends [true]
?
| { readonly [K in keyof A]: Wrap<A[K]> }
| Config<A>
: Config<A>
: Config<A>
Utility type that recursively replaces primitives with Config in a nested
structure.
When to use
Use when typing the input of
unwrap
so callers can pass either a Config
or a record of Configs.
Details
Config.Wrap<{ key: string }> becomes { key: Config<string> } | Config<{ key: string }>
Wrap<function (type parameter) A in type Wrap<A>A> = [type NonNullable<T> = T & {}Exclude null and undefined from T
NonNullable<function (type parameter) A in type Wrap<A>A>] extends [infer function (type parameter) TT] ? [type IsPlainObject<A> = [A] extends [
Record<string, any>
]
? [keyof A] extends [never]
? false
: [keyof A] extends [string]
? true
: false
: false
IsPlainObject<function (type parameter) TT>] extends [true] ?
| { readonly [function (type parameter) KK in keyof function (type parameter) A in type Wrap<A>A]: type Wrap<A> = [NonNullable<A>] extends [
infer T
]
? [IsPlainObject<T>] extends [true]
?
| { readonly [K in keyof A]: Wrap<A[K]> }
| Config<A>
: Config<A>
: Config<A>
Utility type that recursively replaces primitives with Config in a nested
structure.
When to use
Use when typing the input of
unwrap
so callers can pass either a Config
or a record of Configs.
Details
Config.Wrap<{ key: string }> becomes { key: Config<string> } | Config<{ key: string }>
Wrap<function (type parameter) A in type Wrap<A>A[function (type parameter) KK]> }
| interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<function (type parameter) A in type Wrap<A>A>
: interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<function (type parameter) A in type Wrap<A>A>
: interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<function (type parameter) A in type Wrap<A>A>