lukeed / polka

A micro web server so fast, it'll make you dance! :dancers:
MIT License
5.4k stars 172 forks source link

`Polka<Request>.handler` is not assignable to the handler argument of `http.createServer`? #194

Open aradalvand opened 1 year ago

aradalvand commented 1 year ago

The HTTPS example shows app.handler being passed to https.createServer as the request handler, and this does work, but you get type errors when you do it, which leads me to believe there must be something wrong with Polka's types here:

image

This is the case for all three of http, https, and http2.

The error for http.createServer reads:

Argument of type 'Middleware' is not assignable to parameter of type 'RequestListener<typeof IncomingMessage, typeof ServerResponse>'. Target signature provides too few arguments. Expected 3 or more, but got 2.ts(2345)

For https.createServer:

Argument of type 'Middleware' is not assignable to parameter of type 'RequestListener<typeof IncomingMessage, typeof ServerResponse>'.ts(2345)

And http2.createSecureServer:

Argument of type 'Middleware' is not assignable to parameter of type '(request: Http2ServerRequest, response: Http2ServerResponse) => void'. Target signature provides too few arguments. Expected 3 or more, but got 2.ts(2345)