Impact of `S.omit()` on `S.fromKey()` and `S.rename()` Functionality
Is it expected that
S.omit()S.omit() would cause S.fromKey()S.fromKey() or S.rename()S.rename() to stop working?import * as S from '@effect/schema/Schema'
import { pipe } from 'effect/Function'
const schema = S.struct({
a: S.string, b: S.propertySignature(S.literal(1)).pipe(S.fromKey('c'))
})
console.log(S.decodeSync(schema)({ a: 'a', c: 1 }))
// Good, as expected
// { b: 1, a: 'a' }
const schema2 = pipe(
S.struct({
a: S.string, b: S.propertySignature(S.literal(1)).pipe(S.fromKey('c'))
}),
S.omit('a')
)
console.log(S.decodeSync(schema2)({ c: 1 }))
// What?
// Error: ({ b: never } <-> { b: 1 })
// └─ Encoded side transformation failure
// └─ { b: never }
// └─ ["b"]
// └─ is missing
const schema3 = pipe(
S.struct({ a: S.string, b: S.literal(1) }),
S.rename({ b: 'c' }),
)
console.log(S.decodeSync(schema3)({ a: 'a', b: 1 }))
// Good, as expected
// { c: 1, a: 'a' }
const schema4 = pipe(
S.struct({ a: S.string, b: S.literal(1) }),
S.rename({ b: 'c' }),
S.omit('a')
)
console.log(S.decodeSync(schema4)({ b: 1 }))
// What?
// Error: ({ c: never } <-> { c: 1 })
// └─ Encoded side transformation failure
// └─ { c: never }
// └─ ["c"]
// └─ is missingimport * as S from '@effect/schema/Schema'
import { pipe } from 'effect/Function'
const schema = S.struct({
a: S.string, b: S.propertySignature(S.literal(1)).pipe(S.fromKey('c'))
})
console.log(S.decodeSync(schema)({ a: 'a', c: 1 }))
// Good, as expected
// { b: 1, a: 'a' }
const schema2 = pipe(
S.struct({
a: S.string, b: S.propertySignature(S.literal(1)).pipe(S.fromKey('c'))
}),
S.omit('a')
)
console.log(S.decodeSync(schema2)({ c: 1 }))
// What?
// Error: ({ b: never } <-> { b: 1 })
// └─ Encoded side transformation failure
// └─ { b: never }
// └─ ["b"]
// └─ is missing
const schema3 = pipe(
S.struct({ a: S.string, b: S.literal(1) }),
S.rename({ b: 'c' }),
)
console.log(S.decodeSync(schema3)({ a: 'a', b: 1 }))
// Good, as expected
// { c: 1, a: 'a' }
const schema4 = pipe(
S.struct({ a: S.string, b: S.literal(1) }),
S.rename({ b: 'c' }),
S.omit('a')
)
console.log(S.decodeSync(schema4)({ b: 1 }))
// What?
// Error: ({ c: never } <-> { c: 1 })
// └─ Encoded side transformation failure
// └─ { c: never }
// └─ ["c"]
// └─ is missing