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

fix(util-dynamodb): reorder marshall function overload signatures #4829

Merged
merged 2 commits into from Jun 13, 2023

Conversation

pedropedruzzi
Copy link
Contributor

@pedropedruzzi pedropedruzzi commented Jun 12, 2023

The improved ordering of overload signatures ensures more specific ones match before very general ones such as when data is any object or instance.

Issue

Fixes: #4828

Description

This change reorders the overload signatures of the marshall function so that the more specific signatures matches before the more general ones.

Testing

Made sure this compiles:

    const ss: AttributeValue.SSMember = marshall(new Set(['a']));
    const ns: AttributeValue.NSMember = marshall(new Set([0]));
    const bs: AttributeValue.BSMember = marshall(new Set([new Uint8Array()]));
    const s: AttributeValue.SMember = marshall('a');
    const n: AttributeValue.NMember = marshall(0);
    const nil: AttributeValue.NULLMember = marshall(null);
    const bool: AttributeValue.BOOLMember = marshall(false);
    const array: AttributeValue[] = marshall([]);
    const object: Record<string, AttributeValue> = marshall({});

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The improve ordering of overload signatures ensures more specific ones match before very general ones such as when data is any object or instance.
@pedropedruzzi pedropedruzzi requested a review from a team as a code owner June 12, 2023 19:16
@trivikr trivikr merged commit cb4a0e3 into aws:main Jun 13, 2023
2 of 3 checks passed
@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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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