Skip to content

fix(util-dynamodb): replace InstanceType that resolves to any in NativeAttributeValue#7764

Open
TrevorBurnham wants to merge 1 commit intoaws:mainfrom
TrevorBurnham:fix/native-attribute-value-type
Open

fix(util-dynamodb): replace InstanceType that resolves to any in NativeAttributeValue#7764
TrevorBurnham wants to merge 1 commit intoaws:mainfrom
TrevorBurnham:fix/native-attribute-value-type

Conversation

@TrevorBurnham
Copy link
Copy Markdown
Contributor

Fixes #7526

Problem

The NativeAttributeValue type in @aws-sdk/util-dynamodb resolves to any in IDEs and type checking. This is because the union includes:

InstanceType<{ new (...args: any[]): any }>

which TypeScript evaluates to any, poisoning the entire union type. As a result, users get no type validation when using NativeAttributeValue.

Solution

Replace InstanceType<{ new (...args: any[]): any }> with object.

The intent of that union member was to accept class instances when convertClassInstanceToMap is enabled. At the type level, class instances are objects, so object correctly represents this without collapsing the union to any.

The object type in TypeScript represents all non-primitive values, which includes class instances, plain objects, arrays, etc. Since the other union members already cover arrays, records, and Sets specifically, the object member serves as the catch-all for class instances as originally intended.

…veAttributeValue

The NativeAttributeValue type included a union member
`InstanceType<{ new (...args: any[]): any }>` which resolves to `any`,
causing the entire union type to collapse to `any` in IDEs and type
checking. Replace it with `object` which correctly represents class
instances without poisoning the union.

Fixes aws#7526
@TrevorBurnham TrevorBurnham requested a review from a team as a code owner February 22, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NativeAttributeValue type is any

1 participant