Type Checking for Grouping by Kind in TypeScript
Can I get the type checker to actually check this somehow? Seems like pretty much anything passes.
import { Array } from 'effect'
type Value = { kind: 'number'; value: number } | { kind: 'string'; value: string }
const byKind = (
values: Value[],
): {
[K in Value['kind']]?: (Value & { kind: K })[]
} => Array.groupBy(values, ({ kind }) => kind)