Function: readConfig()
function readConfig<S>(
schema,
source,
options?): output<S>;
Defined in: packages/overcast-core/src/config-schema.ts:401
Read schema's fields out of source into the overrides a layer factory is
built with.
Three behaviours worth stating, because each one replaces a hand-rolled copy in every host that reads a config:
- A blank value is an unset value.
FOO=and--foo ""mean "I did not say", not "the empty string", which is what both existing hosts already decided independently. - An unset field is an absent key, never a present
undefined. The layer configs merge overrides by spread, so{ rpcUrl: undefined }overwrites a default rather than falling back to it. Omitting the key is the only shape that composes — and is what an optional zod field does with an absent key. - Every problem is reported at once, named the way this host's user named it. See ConfigError.
The result is typed by the schema rather than as a Partial of the config it
belongs to, which is the more precise of the two: it says the RPC url is a
string and the chain id a number, and says nothing at all about the fields
no string can express.
Type Parameters
| Type Parameter |
|---|
S extends ConfigSchema |
Parameters
| Parameter | Type |
|---|---|
schema | S |
source | ConfigSource |
options | ReadConfigOptions<S> |
Returns
output<S>
Throws
ConfigError when a required field is unset or any value fails its field's parse.