-
-
Notifications
You must be signed in to change notification settings - Fork 805
NitroRoute Serialize Type #2583
Description
Environment
- Operating System: Windows_NT
- Node Version: v20.9.0
- Nitro Version: 2.9.6
- Package Manager: npm@10.1.0
Reproduction
https://stackblitz.com/edit/github-7q39gn?file=_working.ts&view=editor
Describe the bug
In my project I use MongoDB and accordingly the library mongoose. If I now want to return my mongoose response directly in an EventHandler, the object is then of type unknown.
I was able to trace the problem back to the Serialize type of nitro:
https://github.com/unjs/nitro/blob/v2/src/types/fetch/_serialize.ts
Through some tests I was able to determine that the mongoose object runs through the function up to line 43 (ReadonlyArray) the function NonJsonPrimitive has a negative outcome and accordingly Serialize is called recursively. The second itteration is stopped on line 37 and the type is returned on line 38 and then corresponds to unknown.
When I comment out lines 37 and 38 the type is successfully resolved and everything works as desired. Unfortunately I don't know enough about typescript to be able to estimate how the problem can be solved.
Additional context
Logs
No response