Skip to content

The typings on marshall are too narrow #1647

@vivmaha

Description

@vivmaha

Describe the bug
marshall from @aws-sdk/util-dynamodb only accepts data in the form of

{
    [key: string]: NativeAttributeValue;
}

This narrow typing prevents you from using marshall with:

  1. typescript interfaces. If you use a typescript type it works.
  2. arrays. The underlying convertToAttr properly supports this, so why not expose it up?

The v2 sdk's DocumentClient handled both of these cases, so I'm guessing marshall should do the same if parity is a factor.

SDK version number

1.0.0-rc.2

Is the issue in the browser/Node.js/ReactNative?
Node.js

Details of the browser/Node.js/ReactNative version
12

To Reproduce (observed behavior)

interface MyType = {
  foo: string;
  nested: {
    baz: string;
  };
};

const mySimpleObject: MyType = {
  foo: "foo",
  nested: {
    baz: "baz",
  },
};

const x = marshall(mySimpleObject);
^^^^ Argument of type 'MyType' is not assignable to parameter of type '{ [key: string]: NativeAttributeValue; }'.
  Index signature is missing in type 'MyType'.ts(2345)

Expected behavior
I should be able to pass in interface types into marshall. I should be able to also pass in []s.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestNew feature or enhancement. May require GitHub community feedback.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions