Skip to content

Commit 8b87b5e

Browse files
fix: use typed json property to access schema defaults
Use envBaseSchema.json instead of the untyped structure.inner.optional to fix TypeScript compilation error. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 23f5a30 commit 8b87b5e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

tests/benchmark-hwm.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { unlink, writeFile } from 'node:fs/promises'
44

55
import { envBaseSchema } from '../lib/schemas.js'
66

7-
// Get the default value from the schema
8-
const optionals = envBaseSchema.structure?.inner?.optional || []
9-
const hwmNode = optionals.find((n: { key: string }) => n.key === 'STORAGE_HIGH_WATER_MARK')
10-
const CURRENT_HIGH_WATER_MARK = (hwmNode?.default as number) ?? 1024 * 1024
7+
// Get the default value from the schema JSON representation
8+
type SchemaOptional = { key: string; default?: number }
9+
const schemaJson = envBaseSchema.json as { optional?: SchemaOptional[] }
10+
const hwmNode = schemaJson.optional?.find((n) => n.key === 'STORAGE_HIGH_WATER_MARK')
11+
const CURRENT_HIGH_WATER_MARK = hwmNode?.default ?? 1024 * 1024
1112

1213
function formatSize(bytes: number): string {
1314
if (bytes >= 1024 * 1024) return `${bytes / (1024 * 1024)}MB`

0 commit comments

Comments
 (0)