fix(util-dynamodb): replace InstanceType that resolves to any in NativeAttributeValue#7764
Open
TrevorBurnham wants to merge 1 commit intoaws:mainfrom
Open
fix(util-dynamodb): replace InstanceType that resolves to any in NativeAttributeValue#7764TrevorBurnham wants to merge 1 commit intoaws:mainfrom
TrevorBurnham wants to merge 1 commit intoaws:mainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7526
Problem
The
NativeAttributeValuetype in@aws-sdk/util-dynamodbresolves toanyin IDEs and type checking. This is because the union includes:which TypeScript evaluates to
any, poisoning the entire union type. As a result, users get no type validation when usingNativeAttributeValue.Solution
Replace
InstanceType<{ new (...args: any[]): any }>withobject.The intent of that union member was to accept class instances when
convertClassInstanceToMapis enabled. At the type level, class instances areobjects, soobjectcorrectly represents this without collapsing the union toany.The
objecttype 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, theobjectmember serves as the catch-all for class instances as originally intended.