-
-
Notifications
You must be signed in to change notification settings - Fork 630
typeCast Next type appears to be incorrect #3122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@bbugh, could you help with a basic debug (if you can't, I'll try to check it out later)? What would |
Here is further demonstration of the issue. The console output of the following code when typeCast const [rows] = await connection.query(sql, values);
console.log(rows); ❌ Without returning typeCast: (field, next) => { next(); }, // notice no "return"
✅ With returning typeCast: (field, next) => { return next() },
|
Thanks for the debug, @bbugh 🤝
Please, feel free to contribute 🚀 |
Fixes typeCast Next type appears to be incorrect sidorares#3122
Problem
The current return type of
Next
isvoid
. This led to a bug in the code because as currently typed, the return value ofnext
appears to be unnecessary.node-mysql2/typings/mysql/lib/parsers/typeCast.d.ts
Lines 52 to 54 in 9ba3706
I discovered in my code that unless
next()
was returned, this function would result in manyundefined
values. However, in every case that I can find it,next
is called asreturn next()
. If it is not returned, the result is empty data.Additionally, typescript-eslint correctly raises an error on this with the
@typescript-eslint/no-confusing-void-expression
rule:Example 1

Example 2

Proposed solution
Since the return value is required, but the type is not known, the
unknown
type seems like the most correct option here. I tested and this resolves the issue.I can submit a PR if requested (and it will be accepted).
The text was updated successfully, but these errors were encountered: