TypeScript accepts number keys in `Record`, but runtime fails with number keys. Consider restrict...

Schema.Record 's type accepts number typed keys, but fails at runtime. I think it could be restricted to only accept valid property keys?

import { NodeRuntime } from "@effect/platform-node"
import { Effect, Schema as S } from "effect"

export const StringKey = S.String.pipe(S.brand("SKey"))
export type StringKey = typeof StringKey.Type

export const Value = S.Number.pipe(S.brand("Value"))
export type Value = typeof Value.Type

export const MyStringRecord = S.Record({
  key: StringKey,
  value: Value
})

// Runtime failure
export const NumberKey = S.Number.pipe(S.brand("NKey"))
export type NumberKey = typeof NumberKey.Type

export const MyNumberRecord = S.Record({
  key: NumberKey,
  value: Value
})
Was this page helpful?