sveltejs / sapper-template

Starter template for Sapper apps
703 stars 214 forks source link

Type errors after converting to TypeScript #311

Open kapseliboi opened 3 years ago

kapseliboi commented 3 years ago

Node v14.16.0 Npm 6.14.11

I followed the documentation and ran `npx degit "sveltejs/sapper-template#rollup" my-app

cd my-app

npm install

node scripts/setupTypeScript.js

npm install

npm run build`

I expected the build to complete without any errors but multiple errors were found, although it seems that they are related to the same thing (compression middleware). Here is the build output:

`npm run build

TODO@0.0.1 build /redacted/buildDir/my-app sapper build --legacy

Building...

┌──────────────────────────────┐ │ built client with 2 warnings │ └──────────────────────────────┘

@rollup/plugin-typescript TS2769: No overload matches this call. Overload 1 of 2, '(pattern: string | RegExp, ...handlers: (Polka | Middleware)[]): Polka', 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 | Middleware)[]): Polka', gave the following error. Argument of type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to parameter of type 'Polka | Middleware'. Type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to type 'Middleware'. 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:58:2 58 listen(handle: any, callback?: ListenCallback): this;

    The last overload is declared here.

   19.6 kB client.63dc1766.js
           │ src/node_modules/@sapper/app.mjs (35.1%)
           │ node_modules/svelte/internal/index.mjs (24.3%)
           │ src/node_modules/@sapper/internal/App.svelte (14.7%)
           │ src/components/Nav.svelte (7.9%)
           │ src/routes/_error.svelte (7.1%)
           │ src/routes/_layout.svelte (4.5%)
           │ node_modules/svelte/store/index.mjs (3.2%)
           │ src/node_modules/@sapper/internal/manifest-client.mjs (3.0%)
           │ src/client.ts (0.1%)
           └ src/node_modules/@sapper/internal/shared.mjs (0.0%)
     559 B inject_styles.5607aec6.js
           └ inject_styles.js
   1.49 kB index.ea84a0bd.js
           │ src/routes/index.svelte (98.4%)
           └ src/node_modules/images/successkid.jpg (1.6%)
     755 B about.e2ddaf33.js
           └ src/routes/about.svelte
    1.7 kB index.891932d1.js
           └ src/routes/blog/index.svelte
   1.45 kB [slug].ac82799a.js
           └ src/routes/blog/[slug].svelte

┌───────────────────────────────────────┐
│ built client (legacy) with 2 warnings │
└───────────────────────────────────────┘
> @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:58:2
    58  listen(handle: any, callback?: ListenCallback): this;
The last overload is declared here.

33.9 kB client.b2bb186f.js │ node_modules/regenerator-runtime/runtime.js (26.7%) │ src/node_modules/@sapper/app.mjs (25.2%) │ node_modules/svelte/internal/index.mjs (12.6%) │ src/node_modules/@sapper/internal/App.svelte (10.3%) │ src/components/Nav.svelte (6.0%) │ src/routes/_error.svelte (5.6%) │ src/routes/_layout.svelte (4.0%) │ src/node_modules/@sapper/internal/manifest-client.mjs (1.9%) │ node_modules/svelte/store/index.mjs (1.7%) │ node_modules/@babel/runtime/helpers/typeof.js (0.8%) │ node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js (0.6%) │ node_modules/@babel/runtime/helpers/esm/createClass.js (0.6%) │ node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js (0.4%) │ node_modules/@babel/runtime/helpers/esm/inherits.js (0.4%) │ commonjsHelpers.js (0.4%) │ node_modules/@babel/runtime/helpers/esm/typeof.js (0.4%) │ node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/nonIterableRest.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/classCallCheck.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/slicedToArray.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/iterableToArray.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/toConsumableArray.js (0.2%) │ node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js (0.1%) │ node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js (0.1%) │ src/client.ts (0.1%) │ node_modules/@babel/runtime/regenerator/index.js (0.0%) └ src/node_modules/@sapper/internal/shared.mjs (0.0%) 559 B inject_styles.fe622066.js └ inject_styles.js 2.05 kB index.32f208b4.js │ src/routes/index.svelte (98.9%) └ src/node_modules/images/successkid.jpg (1.1%) 1.33 kB about.c4559740.js └ src/routes/about.svelte 2.37 kB index.3bce7dec.js └ src/routes/blog/index.svelte 2.28 kB [slug].51a17a4f.js └ src/routes/blog/[slug].svelte

┌──────────────────────────────┐ │ built server with 2 warnings │ └──────────────────────────────┘

@rollup/plugin-typescript TS2769: No overload matches this call. Overload 1 of 2, '(pattern: string | RegExp, ...handlers: (Polka | Middleware)[]): Polka', 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 | Middleware)[]): Polka', gave the following error. Argument of type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to parameter of type 'Polka | Middleware'. Type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to type 'Middleware'. 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:58:2 58 listen(handle: any, callback?: ListenCallback): this;

    The last overload is declared here.

┌─────────────────────────────────────┐
│ built serviceworker with 2 warnings │
└─────────────────────────────────────┘
> @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:58:2
    58  listen(handle: any, callback?: ListenCallback): this;
The last overload is declared here.

Finished in 10.0s. Type node sapper/build to run the app.`

kapseliboi commented 3 years ago

I created a PR about this in the polka repository https://github.com/lukeed/polka/pull/163 I think I will also create a PR about the compression error as well.