aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

Add ability to create clients without passing configuration in TypeScript

Open trivikr opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe.

The AWS SDK for JavaScript (v3) clients require an empty configuration to be passed in TypeScript. Such requirement didn't exist in AWS SDK for JavaScript (v2).

Code
import AWS from "aws-sdk"; // v2.1092.0
import { DynamoDB } from "@aws-sdk/client-dynamodb"; // v3.54.0

const v2Client = new AWS.DynamoDB();
const v3Client = new DynamoDB();
ts-node output
/local/home/trivikr/.fnm/node-versions/v16.14.0/installation/lib/node_modules/ts-node/src/index.ts:820
    return new TSError(diagnosticText, diagnosticCodes);
           ^
TSError: ⨯ Unable to compile TypeScript:
listTables.ts:5:18 - error TS2554: Expected 1 arguments, but got 0.

5 const v3Client = new DynamoDB();
                   ~~~~~~~~~~~~~~

  node_modules/@aws-sdk/client-dynamodb/dist-types/DynamoDBClient.d.ts:212:17
    212     constructor(configuration: DynamoDBClientConfig);
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    An argument for 'configuration' was not provided.
Screenshot

client-empty-configuration

The configuration is not actually needed, as client works fine without any value passed in constructor parameters in JavaScript.

Code
import { DynamoDB } from "@aws-sdk/client-dynamodb"; // v3.54.0

const v3Client = new DynamoDB();
console.log(await v3Client.listTables({ Limit: 1 }));

Output
{
  '$metadata': {
    httpStatusCode: 200,
    requestId: 'M6GPIMAI380CVPICA1UTC932VVVV4KQNSO5AEMVJF66Q9ASUAAJG',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  LastEvaluatedTableName: 'TABLE_NAME',
  TableNames: [ 'TABLE_NAME' ]
}

Describe the solution you'd like

Add default parameter as {} for ClientConfig so that clients can be created without explicitly passing {}

Describe alternatives you've considered

N/A

trivikr avatar Mar 11 '22 23:03 trivikr