anacronw / multer-s3

multer storage engine for amazon s3
MIT License
660 stars 190 forks source link

Type issue with multer-s3 3.0.1 and @aws-sdk/client-s3 #173

Closed Arteneko closed 2 years ago

Arteneko commented 2 years ago

Following the example in the README, using S3 instead of S3Client, I obtain this error of missing parameters...

Type 'S3' is missing the following properties from type 'S3': getBucketLifecycle, getBucketNotification, putBucketLifecycle, putBucketNotification, and 11 more.ts(2740)
index.d.ts(13, 5): The expected type comes from property 's3' which is declared here on type 'Options'
import multers3 from 'multer-s3';
import { S3 } from '@aws-sdk/client-s3';

const s3 = new S3({});
return {
    storage: multers3({
        s3,
        contentType: multers3.AUTO_CONTENT_TYPE,
        bucket: config.get<string>('S3_BUCKET'),
        key: function (req, file, cb) {},
    }),
};

Since I had to change S3Config to S3 (as S3config had many more errors), is there anything else I'm missing?

Arteneko commented 2 years ago

Edit: I just noticed the typings for multer-s3 seems to be out of date, as they still target multer-s3 v2...

// Type definitions for multer-s3 2.7

Using the AWS SDK v2 with multer v3.0.1 and the current typings correct the error, but obviously breaks the code

LinusU commented 2 years ago

This package doesn't ship with types, so you'll have to file an issue at DefinitelyTyped instead