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

[util-dynamodb] marshall overload signatures are broken due to more general overload matching first #4828

Open
3 tasks done
pedropedruzzi opened this issue Jun 12, 2023 · 4 comments · Fixed by #4829
Open
3 tasks done
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue queued This issues is on the AWS team's backlog

Comments

@pedropedruzzi
Copy link
Contributor

Checkboxes for prior research

Describe the bug

A number of fine grained overload signatures were added to the marshall function by PR #3539. In theory this improvement would allow the return of e.g. marshall(10) to be detected as having type AttributeValue.NMember and so forth.

However, this doesn't currently work because the object/map sinature apparently matches any type, so the next signatures don't ever get a chance to match.

SDK version number

@aws-sdk/util-dynamodb@3.350.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.16.0

Reproduction Steps

Just try to tsc the follow TS snippet:

import { AttributeValue } from '@aws-sdk/client-dynamodb';
import { marshall } from '@aws-sdk/util-dynamodb';

const attributeValue: AttributeValue = marshall(10);

Observed Behavior

The above code fails to TS compile with error Type 'Record<string, AttributeValue>' is not assignable to type 'AttributeValue'. because the return is incorrectly detected as Record<string, AttributeValue>.

Expected Behavior

No TS compilation errors. According to overload signature export declare function marshall(data: number, options?: marshallOptions): AttributeValue.NMember;, the call marshall(10) should return type AttributeValue.NMember instead which is assignable to AttributeValue.

Possible Solution

Rearrange the order of overload signature moving the more general one to the end of the list. Will send a PR shortly.

Additional Information/Context

No response

@pedropedruzzi pedropedruzzi added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 12, 2023
@RanVaknin
Copy link
Contributor

Hi @pedropedruzzi ,

Thanks for opening this issue. I'm able to confirm that this is an issue. Will review this with the team.

Thanks,
Ran~

@RanVaknin RanVaknin self-assigned this Jun 13, 2023
@RanVaknin RanVaknin added needs-review This issue/pr needs review from an internal developer. p2 This is a standard priority issue queued This issues is on the AWS team's backlog and removed needs-triage This issue or PR still needs to be triaged. needs-review This issue/pr needs review from an internal developer. labels Jun 13, 2023
@github-actions
Copy link

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.

@trivikr
Copy link
Member

trivikr commented Jul 3, 2023

Reopening, as the fix was reverted in #4909

@trivikr trivikr reopened this Jul 3, 2023
@erik-singleton
Copy link

Were there reports of broken types that led to this revert?

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 queued This issues is on the AWS team's backlog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants