deligenius / aws-sdk-v3-nest

AWS SDK V3 dynamic module for NestJS
MIT License
40 stars 5 forks source link

Unable to resolve signature of parameter decorator #2

Closed devotoare closed 1 year ago

devotoare commented 1 year ago

Tried using this today and followed the simple directions, but receive this error:

src/app.controller.ts:7:16 - error TS1239: Unable to resolve signature of parameter decorator when called as an expression.
  Argument of type 'undefined' is not assignable to parameter of type 'string | symbol'.

7   constructor(@InjectAws(S3Client) private readonly s3: S3Client) {}
                 ~~~~~~~~~~~~~~~~~~~

My app.controller.ts:

import { ListBucketsCommand, S3Client } from '@aws-sdk/client-s3';
import { Controller, Get } from '@nestjs/common';
import { InjectAws } from 'aws-sdk-v3-nest';

@Controller()
export class AppController {
  constructor(@InjectAws(S3Client) private readonly s3: S3Client) {}

  @Get('')
  async test(): Promise<any> {
    const listCommand = new ListBucketsCommand({});
    const res = await this.s3.send(listCommand);
    return res;
  }
}

My app.module.ts:

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AwsSdkModule } from 'aws-sdk-v3-nest';
import { S3Client } from '@aws-sdk/client-s3';
import { PrismaService } from './prisma.service';

@Module({
  imports: [
    AwsSdkModule.register({
      isGlobal: true,
      client: new S3Client({
        region: 'us-east-1'
      }),
    }),
  ],
  controllers: [AppController],
  providers: [PrismaService],
})
export class AppModule {}
gjuoun commented 1 year ago

Hi I'm not able to reproduce,

can you provide more information?

jayalfredprufrock commented 1 year ago

I had this problem too. It turned out to be a typescript version mismatch between what my project was using (v4) and what was loaded in VSCode (v5). The error will go away when you either upgrade your project, or tell VsCode to use the version of Typescript that is installed in node_modules