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

[Bug]: The promise() APIs are not removed from functions if the client is created in constructor #836

Closed
1 task
trivikr opened this issue Apr 10, 2024 · 1 comment · Fixed by #843
Closed
1 task
Labels
bug Something isn't working

Comments

@trivikr
Copy link
Member

trivikr commented Apr 10, 2024

Self-service

  • I'd be willing to implement a fix

Describe the bug

The promise() APIs are not removed from functions if the client is created in constructor

Steps to reproduce

import AWS from "aws-sdk";

// Client as class member
class ClientClassMember {
  clientInClass: AWS.DynamoDB;
  
  constructor() {
    this.clientInClass = new AWS.DynamoDB();
  }

  async listTables() {
    return await this.clientInClass.listTables().promise();
  }

  async listTagsOfResource() {
    return await this.clientInClass.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
  }
}

Observed behavior

import { DynamoDB } from "@aws-sdk/client-dynamodb";

// Client as class member
class ClientClassMember {
  clientInClass: DynamoDB;
  
  constructor() {
    this.clientInClass = new DynamoDB();
  }

  async listTables() {
    return await this.clientInClass.listTables().promise();
  }

  async listTagsOfResource() {
    return await this.clientInClass.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
  }
}

Expected behavior

import { DynamoDB } from "@aws-sdk/client-dynamodb";

// Client as class member
class ClientClassMember {
  clientInClass: DynamoDB;
  
  constructor() {
    this.clientInClass = new DynamoDB();
  }

  async listTables() {
    return await this.clientInClass.listTables();
  }

  async listTagsOfResource() {
    return await this.clientInClass.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
  }
}

Environment

aws-sdk-js-codemod: 1.2.6
- jscodeshift: 0.15.2
- recast: 0.23.4

Additional context

No response

Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant