Schema.Record doesn't support Schema.Enums as key
joepjoosten opened this issue · comments
Joep Joosten commented
What version of Effect is running?
3.1.5, @effect/schema 0.67.3, Typescript 5.4.5
What steps can reproduce the bug?
import { Schema } from "@effect/schema";
enum Abc {
A = 'a',
B = 'b',
C = 'c'
}
const abc = Schema.Enums(Abc);
const def = Schema.Record(abc, Schema.String);
type def = Schema.Schema.Type<typeof def>;
const test: def = {
[Abc.A]: 'test'
}
What is the expected behavior?
In typescript it's valid to use:
enum Abc {
A = 'a',
B = 'b',
C = 'c'
}
const test: Record<Abc, string> = {
[Abc.A]: 'test'
}
What do you see instead?
Error: record: unsupported key schema (<enum 3 value(s): 0 | 1 | 2>)
at key (/node_modules/.pnpm/@effect+schema@0.67.3_effect@3.1.5/node_modules/@effect/schema/src/AST.ts:2015:15)
at record (/node_modules/.pnpm/@effect+schema@0.67.3_effect@3.1.5/node_modules/@effect/schema/src/AST.ts:2018:3)
at getDefaultTypeLiteralAST (/node_modules/.pnpm/@effect+schema@0.67.3_effect@3.1.5/node_modules/@effect/schema/src/Schema.ts:2317:57)
at makeTypeLiteralClass (/node_modules/.pnpm/@effect+schema@0.67.3_effect@3.1.5/node_modules/@effect/schema/src/Schema.ts:2348:18)
at makeRecordClass (/node_modules/.pnpm/@effect+schema@0.67.3_effect@3.1.5/node_modules/@effect/schema/src/Schema.ts:2411:29)
at Record (/node_modules/.pnpm/@effect+schema@0.67.3_effect@3.1.5/node_modules/@effect/schema/src/Schema.ts:2428:3)
Additional information
No response