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

Overlays break many constructor inputs #725

Open
cameroncf opened this issue Apr 23, 2024 · 0 comments
Open

Overlays break many constructor inputs #725

cameroncf opened this issue Apr 23, 2024 · 0 comments

Comments

@cameroncf
Copy link

I'm following the overlay guidance found in the docs and it looks like when overlays are used, a lot of options are statically configured inside the overlay definition and cannot be modified in the constructor.

In the following example, timestamps are set to true in the type definition (source), which causes an error when I try to set timestamps to false in the constructor.

new Entity<"Foo", FooItem, CompositeKey, typeof table>({
  name: "Foo",

  // !!! ERROR !!! : Type 'false' is not assignable to type 'true'.ts(2322)
  timestamps: false,

  attributes: {
    pk: { partitionKey: true },
    sk: { sortKey: true },
  },

  table,
} as const);

I can "fix" this by giving a more elaborate overlay definition like so, which changes (corrects?) the type and allows input again.

new Entity<
  "Foo",
  FooItem,
  CompositeKey,
  typeof table,
  boolean,
  boolean,
  boolean,
  string,
  string
>({
  name: "Foo",

  // it works now!
  timestamps: false,

  attributes: {
    pk: { partitionKey: true },
    sk: { sortKey: true },
  },

  table,
} as const);

I'm admittedly not a Typescript wizard so I may be doing something wrong (and please correct me if I am), but this doesn't seem to be expected behavior.

  • dynamodb-toolbox v0.9.3
@cameroncf cameroncf changed the title Overlays breaks many constructor inputs Overlays break many constructor inputs Apr 23, 2024
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

No branches or pull requests

1 participant