Closed motzyball closed 3 years ago
I created an issue in the sapper-template repo here as I'm experiencing the same: https://github.com/sveltejs/sapper-template/issues/300
I had thought this was just an incompatibility with the Express types, but I guess it happens with polka too.
@motzyball You can cast sapper.middleware() as any
to allow it to build; it doesn't have to be a blocking upgrade (depending on how strict your ts config is)
Seems like the typings for that changed in #1604 . The quick fix for this issue might be to make search
optional, although I don't know if that's semantically correct (don't know much of the Sapper typings). If that fixes the other liked error - I don't know, because the error message does not say why the other overloads don't apply.
I'm still experiencing this. Steps to reproduce:
npx degit "sveltejs/sapper-template#rollup" my-app
cd my-app
node scripts/setupTypeScript.js
npm install
npm run dev
Leads to:
• service worker
@rollup/plugin-typescript TS2769: No overload matches this call.
Overload 1 of 2, '(pattern: string | RegExp, ...handlers: (Polka<Request> | Middleware<Request>)[]): Polka<Request>', gave the following error.
Argument of type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to parameter of type 'string | RegExp'.
Type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is missing the following properties from type 'RegExp': exec, test, source, global, and 12 more.
Overload 2 of 2, '(...handlers: (Polka<Request> | Middleware<Request>)[]): Polka<Request>', gave the following error.
Argument of type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to parameter of type 'Polka<Request> | Middleware<Request>'.
Type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to type 'Middleware<Request>'.
Types of parameters 'req' and 'req' are incompatible.
Type 'Request' is missing the following properties from type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>': get, header, accepts, acceptsCharsets, and 21 more.
11 compression({ threshold: 0 }),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@rollup/plugin-typescript TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type '(err: any) => void' is not assignable to parameter of type 'ListenCallback'.
15 .listen(PORT, err => {
~~~~~~~~
node_modules/polka/index.d.ts:61:2
61 listen(handle: any, callback?: ListenCallback): this;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The last overload is declared here.
Describe the bug I upgraded Sapper in a new
sveltejs/sapper-template
rollup project and see Typescript errors when runningnpm i && npm run dev
Logs
(Repeated for client, server, and service-worker)
To Reproduce
sveltejs/sapper-template
v0.29.0
npm i && npm run dev
, errors reported in consoleInformation about your Sapper Installation:
Severity Blocking upgrade, which is important for us because it seems to fix issues we have with
preload
not firing consistently (https://github.com/sveltejs/sapper/issues/1582)