t3-code-android-nightly/.repos/effect-smol/packages/tools/bundle/fixtures/schema-representation-roundtrip.ts
Julius Marminge e3c85ead63
chore(refs): sync Effect and Alchemy references to rc.115 and beta.78 (#12327)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-17 23:21:25 -07:00

15 lines
547 B
TypeScript

import * as Schema from "effect/Schema"
import * as SchemaRepresentation from "effect/SchemaRepresentation"
const schema = Schema.toCodecJson(Schema.Struct({
a: Schema.String,
b: Schema.optional(Schema.FiniteFromString),
c: Schema.Array(Schema.String)
}))
const json = SchemaRepresentation.toJson(SchemaRepresentation.toRepresentation(schema.ast))
export const roundtrip = SchemaRepresentation.fromRepresentation(
SchemaRepresentation.fromJson(JSON.parse(JSON.stringify(json))),
{ revivers: [SchemaRepresentation.isFiniteReviver] }
)