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

[BUG] Return type of model.get is missing | undefined #1622

Open
6 tasks done
JaakkoLipsanen opened this issue Jul 27, 2023 · 0 comments · May be fixed by #1675
Open
6 tasks done

[BUG] Return type of model.get is missing | undefined #1622

JaakkoLipsanen opened this issue Jul 27, 2023 · 0 comments · May be fixed by #1675

Comments

@JaakkoLipsanen
Copy link

JaakkoLipsanen commented Jul 27, 2023

Summary:

Return type of Model<T>.get is T, even though it returns undefined if item is not found. This behavior is also mentioned in the documentation.

Code sample:

Schema

const UserSchema = ...

Model

const UserModel = dynamoose.model<UserItem>(tableName, UserSchema);

General

const user = UserModel.get('non-existing-id');

Current output and behavior (including stack trace):

// type of user is UserItem

Expected output and behavior:

// type of user should be UserItem | undefined

Environment:

Dynamoose version: 3.2.0

Other:

  • I have read through the Dynamoose documentation before posting this issue
  • I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
  • I have searched the internet and Stack Overflow to ensure this issue hasn't been raised or answered before
  • I have tested the code provided and am confident it doesn't work as intended
  • I have filled out all fields above
  • I am running the latest version of Dynamoose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant