Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type assignment errors #6420

Open
3 tasks done
menkari opened this issue Aug 29, 2024 · 3 comments
Open
3 tasks done

Type assignment errors #6420

menkari opened this issue Aug 29, 2024 · 3 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Comments

@menkari
Copy link

menkari commented Aug 29, 2024

Checkboxes for prior research

Describe the bug

Brand new application, I'm receiving argument type errors when instantiating the S3Client and assigning any operation to the .send() function.

new S3Client error:

Argument type {region: string} is not assignable to parameter type __CheckOptionalClientConfig<S3ClientConfig>

.send() command error:

Argument type ListBucketsCommand is not assignable to parameter type Command<ServiceInputTypes, SI, ServiceOutputTypes, SO, SmithyResolvedConfiguration<__HttpHandlerOptions>>

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Browser

Details of the browser/Node.js/ReactNative version

v20.16.0

Reproduction Steps

This looks to be a continuation of #4928

Minimally reproducible application using Angular 18 via ng-cli, vanilla setup, SCSS.

home.component.ts

import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import {S3Client} from "@aws-sdk/client-s3";

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss'
})
export class AppComponent {
  title = 'awsTester';

  s3Client: S3Client;

  constructor() {

    console.log("Testing S3...");

    this.s3Client = new S3Client({
      region: 'ap-southeast-2'
    });

  }

}

package.json

{
  "name": "aws-tester",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^18.1.0",
    "@angular/common": "^18.1.0",
    "@angular/compiler": "^18.1.0",
    "@angular/core": "^18.1.0",
    "@angular/forms": "^18.1.0",
    "@angular/platform-browser": "^18.1.0",
    "@angular/platform-browser-dynamic": "^18.1.0",
    "@angular/router": "^18.1.0",
    "@aws-sdk/client-s3": "^3.637.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^18.1.3",
    "@angular/cli": "^18.1.3",
    "@angular/compiler-cli": "^18.1.0",
    "@types/jasmine": "~5.1.0",
    "jasmine-core": "~5.1.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.5.2"
  }
}

Observed Behavior

Unable to compile the application due to argument type errors

Expected Behavior

The application should function according to API documentation with the prescribed types.

Possible Solution

Unknown. Have seen this issue previously. Fixes weren't conveyed. Have attempted package.json lock file and node-modules folder delete. Have started from scratch with no success either.

Additional Information/Context

Currently using webstorm, macos

@menkari menkari added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 29, 2024
@menkari
Copy link
Author

menkari commented Aug 29, 2024

yeah @africanobyamugisha I'm pretty sure sending someone a random zip file ain't the solution bro 🤪

@zshzbh zshzbh self-assigned this Aug 29, 2024
@zshzbh
Copy link

zshzbh commented Aug 30, 2024

Hey @menkari ,

Thanks for the feedback! However I can't reproduce this issue. Code I have :

import { S3Client, ListObjectsCommand } from "@aws-sdk/client-s3";

// Create an S3 client
var config = {
  region: "us-east-1",
  credentials: {
    accessKeyId: "***",
    secretAccessKey: "***",
  },
};

const client = new S3Client(config);
var bucketParams = { Bucket: "new-bucket-maggie-ma" };

var listObjectsCommand = new ListObjectsCommand(bucketParams);
client
  .send(listObjectsCommand)
  .then(function (data) {
    console.log("Success", data);
  })
  .catch(function (err) {
    console.error(err);
  });

In order to find the root cause, could you please send over the parameters that you put on the ListBucketsCommand?

Thanks!
Maggie

@zshzbh zshzbh added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Aug 30, 2024
@menkari
Copy link
Author

menkari commented Aug 30, 2024

@zshzbh Its every command, not just ListBucketsCommand - As I understand, the command doesn't require any parameters anyway. But even with the most basic of GetObjectCommand

const response = this.s3Client.send(new GetObjectCommand({
      Bucket: 'my-bucket',
      Key: 'my-key'}
    }));

Also returns the type error of

Argument type GetObjectCommand is not assignable to parameter type Command<ServiceInputTypes, SI, ServiceOutputTypes, SO, SmithyResolvedConfiguration<__HttpHandlerOptions>>

I've pushed the minimal application here for cloning: https://github.com/neon-light-dev/awsTester

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Projects
None yet
Development

No branches or pull requests

4 participants
@menkari @zshzbh and others