[fix] `encoding` is still required in TS even though it has default value from `co-body`
JeromeDeLeon opened this issue · comments
Describe the bug
Node.js version: 18.6.1
OS version: macOS 12.6
Description: When I used the v5 of this lib, I am getting a type error from the encoding
field being required but the README.md
says that it has a default value suggesting it isn't required.
Line 50 in 664cd7c
Another thing is that encoding
is not being passed on to the co-body
's parse
function so it seems useless compared to v4 where it uses copy-to
's copy
function to merge options.
Lines 50 to 111 in 5678a79
compared to v5 where it limits the options
Lines 63 to 73 in 664cd7c
so I'm not entirely sure if we should document this as breaking changes that we're not able to override the encoding
or any other values or fix this type of issue.
Also, I think it's an issue with co-body
type declaration where they explicitly put undefined
as part of the type telling us to explicitly pass a value of undefined
Actual behavior
Argument of type '{ jsonLimit: string; }' is not assignable to parameter of type 'BodyParserOptions'.
Property 'encoding' is missing in type '{ jsonLimit: string; }' but required in type 'Pick<Options, "encoding">'.ts(2345)
Expected behavior
Should not be getting any type of error
Code to reproduce
For whatever reason, I wasn't able to replicate it in the TS playground but I was able to replicate it in CodeSandbox.
Workaround
bodyParser({ ...yourOptions, encoding: undefined }) // only if you're not overriding it
Checklist
- I have searched through GitHub issues for similar issues.
- I have completely read through the README and documentation.
- I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
Thanks @JeromeDeLeon for your catch! Yup, it looks like an issue with the co-body, and from our side we don't pass the encoding option ... I am working on it and expect the new release soon!