Skip to content

refactor: type-safe config#22445

Merged
spalladino merged 11 commits intomerge-train/spartanfrom
nikita/config-types
Apr 14, 2026
Merged

refactor: type-safe config#22445
spalladino merged 11 commits intomerge-train/spartanfrom
nikita/config-types

Conversation

@deffrian
Copy link
Copy Markdown
Collaborator

@deffrian deffrian commented Apr 9, 2026

Ref: A-175

  • Add type parameter to ConfigMapping<T>
  • Replace ConfigMappingsType<T> = Record<keyof T, ConfigMapping<any>> with a per-key mapped type: { [K in keyof T]-?: ConfigMapping<Required<T>[K]> }
  • parseEnv must return T or throw — empty strings are treated as "not set" before parseEnv is called
  • Fix spread ordering bug in sequencerClientConfigMappings where narrow l1Contracts from chainConfigMappings was overwriting the full set from l1ReaderConfigMappings

@deffrian deffrian changed the title Nikita/config types refactor: type-safe config Apr 9, 2026
// Parse the value if needed
if (value !== undefined) {
// Parse the value if needed. Empty strings are treated as "not set".
if (value) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but would prefer explicitly checking for value !== undefined && value !== '' just because JS truthy checks can get dodgy (it should be fine now that value is string | undefined but just to be extra safe)

@spalladino spalladino merged commit 3aa889e into merge-train/spartan Apr 14, 2026
12 checks passed
@spalladino spalladino deleted the nikita/config-types branch April 14, 2026 14:42
spalladino pushed a commit that referenced this pull request Apr 14, 2026
## Summary
Fixes two TypeScript type errors introduced by PR #22445 (refactor:
type-safe config).

`ConfigMappingsType<T>` uses `Required<T>[K]` to derive the `parseEnv`
return type, so for optional `number` fields, `parseEnv` must return
`number` — not `number | undefined`. The `undefined` case for missing
env vars is already handled by the config framework before `parseEnv` is
called.

- `stdlib/src/config/sequencer-config.ts`:
`attestationPropagationTime.parseEnv` now returns `number` instead of
`number | undefined`
- `p2p/src/config.ts`: `l1PublishingTime.parseEnv` now returns `number`
instead of `number | undefined`

ClaudeBox log: https://claudebox.work/s/1b406eba6bceb29c?run=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants