aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
2.96k stars 556 forks source link

`@smithy/types` clients mistype `CloudFormation.describeStacks` #6065

Closed wuhkuh closed 1 month ago

wuhkuh commented 2 months ago

Checkboxes for prior research

Describe the bug

When I'm casting a CloudFormation instance as one (or more) Smithy types (NodeJsClient, AssertiveClient, ...), it loses the type information.

Update: Apparently this has a wider scope than just the method I'm interested in.

SDK version number

@aws-sdk/client-cloudformation@3.569.0 @smithy/types@2.12.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.12.2

Reproduction Steps

import { type AssertiveClient } from "@smithy/types";
import { CloudFormation } from "@aws-sdk/client-cloudformation";

const client = new CloudFormation({}) as AssertiveClient<CloudFormation>;
const describeStacksResponse = await client.describeStacks({
  StackName: STACK_NAME
});

Observed Behavior

You will see the following TypeScript error:

No overload matches this call.
  Overload 1 of 4, '(command: Command<object, object, { $metadata: { httpStatusCode?: number | undefined; requestId?: string | undefined; extendedRequestId?: string | undefined; cfId?: string | undefined; attempts?: number | undefined; totalRetryDelay?: number | undefined; }; }, { ...; }, unknown>, options?: any): Promise<...>', gave the following error.
    Object literal may only specify known properties, and 'StackName' does not exist in type 'Command<object, object, { $metadata: { httpStatusCode?: number | undefined; requestId?: string | undefined; extendedRequestId?: string | undefined; cfId?: string | undefined; attempts?: number | undefined; totalRetryDelay?: number | undefined; }; }, { ...; }, unknown>'.
  Overload 2 of 4, '(command: Command<object, object, { $metadata: { httpStatusCode?: number | undefined; requestId?: string | undefined; extendedRequestId?: string | undefined; cfId?: string | undefined; attempts?: number | undefined; totalRetryDelay?: number | undefined; }; }, { ...; }, unknown>, options?: any, cb?: ((err: any, data?: { ...; } | undefined) => void) | undefined): void | Promise<...>', gave the following error.
    Object literal may only specify known properties, and 'StackName' does not exist in type 'Command<object, object, { $metadata: { httpStatusCode?: number | undefined; requestId?: string | undefined; extendedRequestId?: string | undefined; cfId?: string | undefined; attempts?: number | undefined; totalRetryDelay?: number | undefined; }; }, { ...; }, unknown>'.
ts(2769)

Expected Behavior

No type errors, like other method calls for the constructed client.

Possible Solution

No response

Additional Information/Context

It's incredibly hard to step through the generated types. It's definitely a problem related to Smithy code generation.

kuhe commented 1 month ago

dev note: likely due to interaction between the all-optional args generating an additional no-arg method signature and the type transform only seeing the first available signature

kuhe commented 1 month ago

a fix has been applied as of this version: https://www.npmjs.com/package/@aws-sdk/client-cloudformation/v/3.575.0, using ^3.0.0 of @smithy/types.

github-actions[bot] commented 1 month ago

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.