feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.03k stars 748 forks source link

Breaking issue: Upgrade to v5.0.1 fails on - koa__multer "All declarations of 'files' must have identical modifiers." #3112

Closed tvld closed 1 year ago

tvld commented 1 year ago

Tried to upgrade from v5.0.0 to v5.0.1 but that fails immediately. Serious breaking issue. Adding to the disaster: I can not seem to be able to downgrade :(

npm run compile

> bligback@0.6 compile
> shx rm -rf lib/ && tsc

node_modules/@types/koa__multer/index.d.ts:48:9 - error TS2687: All declarations of 'files' must have identical modifiers.

48         files: { [fieldname: string]: multer.File[] } | multer.File[] | undefined;
           ~~~~~

node_modules/@types/koa__multer/index.d.ts:48:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'files' must be of type 'Files | undefined', but here has type 'File[] | { [fieldname: string]: File[]; } | undefined'.

48         files: { [fieldname: string]: multer.File[] } | multer.File[] | undefined;
           ~~~~~

  node_modules/koa-body/lib/index.d.ts:9:9
    9         files?: Files;
              ~~~~~
    'files' was also declared here.

node_modules/koa-body/lib/index.d.ts:9:9 - error TS2687: All declarations of 'files' must have identical modifiers.

9         files?: Files;
          ~~~~~

Found 3 errors in 2 files.

Errors  Files
     2  node_modules/@types/koa__multer/index.d.ts:48
     1  node_modules/koa-body/lib/index.d.ts:9

Same results after:

rm -rf ./node_modules
npm install
luciamaj commented 1 year ago

I also run into the same issue, I manage to resolve it uninstalling @types/koa__multer and importing koa/multer like this let multer = require('@koa/multer');

tvld commented 1 year ago
let multer = require('@koa/multer'); // >> ??

Where would you do that? So you do not use types at all for koa then?

luciamaj commented 1 year ago
let multer = require('@koa/multer'); // >> ??

Where would you do that? So you do not use types at all for koa then?

I changed the import in the service where I'm using Multer for file uploads. I'm not using types only for Koa Multer because the TypeScript error seems to suggest an incompatibility between Koa Multer and Koa Body. There are certainly more elegant ways to solve the problem, but I needed a quick fix.

tvld commented 1 year ago

Seems I solved it by completely removing the package:

npm rm @types/koa__multer

Both npm run dev and npm run compile seems to be fine. Will test a bit more, but so far no complaints... hmm ))

8BallBomBom commented 1 year ago

Is there any specific reason for using @koa/multer? The newly included koa-body package which replaced koa-bodyparser handles file uploads and multipart/form-data among other things.

As you can see it is imported here and then exported as bodyParser on the @feathersjs/koa package.

tvld commented 1 year ago

I can confirm that all day working without npm rm @types/koa__multer gave no errors... So, I suppose the package is not needed...