fix: Made field-less Schema.Struct({}) respect onExcessProperty: 'ignore' | 'preserve' | 'error'#2503
fix: Made field-less Schema.Struct({}) respect onExcessProperty: 'ignore' | 'preserve' | 'error'#2503nikelborm wants to merge 1 commit into
Schema.Struct({}) respect onExcessProperty: 'ignore' | 'preserve' | 'error'#2503Conversation
🦋 Changeset detectedLatest commit: 3c65513 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
8c6e994 to
65d6a19
Compare
Schema.Struct({}) respect onExcessProperty: 'ignore' | 'preseve' | 'error'Schema.Struct({}) respect onExcessProperty: 'ignore' | 'preserve' | 'error'
be3e7f5 to
f570b28
Compare
…ignore' | 'preserve' | 'error'`
f570b28 to
3c65513
Compare
|
Hi @nikelborm, The Effect V4 codebase has been merged back into GitHub cannot transfer pull requests between repositories. If you would like to continue this contribution, please open a replacement pull request against After opening the replacement, please reply here with its URL so maintainers can verify the migration and close this source PR. |
|
I had a mirror PR opened against v3 Effect-TS/effect#6298 Should I close it and create a new one, or should I overwrite the changes in that one? |
|
@nikelborm - the Effect v3 codebase still lives on the So I would suggest opening a companion PR targeting |
Type
Description
Motivation: you remove one field in the schema; the decoded object gets fewer fields. You remove another; fewer again. You remove the last; suddenly, all the fields come back, regardless of the default
onExcessProperty: "ignore". If the user wants to retrieve all fields, they can setonExcessProperty: "preserve".I tried to defend old behavior with "
{}meanstypeof obj === 'object' && obj !== nulland effect's schema tries to be closer to TypeScript's behaviour, by treatingSchema.Struct({})as something passing the condition". And this might hold in isolation. But considering the context, by this logic, any fields which are not explicitly mentioned inSchema.Struct({ ... })should be preserved in all decoded objects, not only the ones that have{}signature, to follow TypeScript's assignability rules. And this is not what happens. The behavior should be consistent between field-less and field-ful structs.Related
Schema.Struct({})respectonExcessProperty: 'ignore' | 'preserve' | 'error'effect#6298