-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[fix] Has callback() changed return type? Now error from eslint #1755
Comments
In the meantime added issue to DefinitelyTyped |
This change (the one referenced in your issue on the |
@crystalfp did you try something like this import http2 from "node:http2";
import fs from "node:fs";
import Koa from "koa";
const options = {
key: fs.readFileSync("./cert/localhost-privkey.pem"),
cert: fs.readFileSync("./cert/localhost-cert.pem"),
};
const port = 3322;
const runApp = () => {
console.log("Running");
};
const handleServerErrors = (error) => {
console.log("Error", error);
};
const app = new Koa();
const startServer = async () => {
const server = http2.createSecureServer(options, app.callback());
server.listen(port, () => runApp()).once("error", handleServerErrors);
};
startServer(); |
This is exactly my code (also in my first question BTW). The problem is the typing of |
@crystalfp This should be fixed on the
|
Describe the bug
The following ts code has always worked:
Node.js version: 19.8.1
OS version: Windows 11 64 bits
Koa version: 2.14.1
@types/koa version: 2.13.6
Description: Wrong type for the app.callback() function.
Actual behavior
eslint
complains:Promise returned in function argument where a void return was expected (@typescript-eslint/no-misused-promises)
at the marked line. Is it my fault (but always compiled clearly) or the typing is wrong? That is, has the function changed and I should change the code or is it an error in@types/koa
?Expected behavior
No complains from eslint.
Code to reproduce
See above
Checklist
The text was updated successfully, but these errors were encountered: