Hooks values originalDoc
and previousDoc
are badly typed
#1851
peufo
started this conversation in
Feature Requests & Ideas
Replies: 1 comment
-
Hey @peufo — thanks for bringing this up! Yes, it certainly does overlap with #1563. We have some big TS stuff in the works that I am VERY excited about and this will be resolved alongside that roadmap item as you expected! In the meantime, I'm going to convert this to a discussion because this is more about improving our type accuracy rather than something explicitly broken, but we can keep the conversation going there. How's that? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Report
The values
originalDoc
andpreviousDoc
passed to functions of typeFieldHook
,CollectionBeforeChangeHook
andCollectionAfterChangeHook
do not match.There is no distinction between
beforeChange
andafterChange
field hooks. This makes in thebeforeChange
hook,previousDoc
is typed as defined when it is not (as mentioned in the documentation)In most cases, the document has "_id" and "__v" fields instead of simple "id".
Steps to Reproduce
Create this collection config :
See the console output when you create or update a doc:
Other Details
I think this is partly in line with this issue #1563
Thank you for this ambitious and forward-looking project 👏
Beta Was this translation helpful? Give feedback.
All reactions