You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe the parameter type for Model.create() is incorrect. It is currently Partial<T>, but I believe it would be more appropriate to use T instead to warn users when required fields are missing from a new item.
For example, you can create an item using Model.create() where you pass in a Partial<T>, then when you fetch that item using Model.get() it will return a Promise<T>. Now your types won't match your object.
Code sample:
Schema
// Strongly typed model
class Cat extends Item {
id: number;
name: string;
}
Current output and behavior (including stack trace):
Using the example from the docs, that create call won't cause any type errors.
Expected output and behavior:
I believe this should cause a type error, because the Cat class contains a name field which is not optional and create shouldn't allow you to pass in an invalid object.
Summary:
I believe the parameter type for
Model.create()
is incorrect. It is currentlyPartial<T>
, but I believe it would be more appropriate to useT
instead to warn users when required fields are missing from a new item.For example, you can create an item using
Model.create()
where you pass in aPartial<T>
, then when you fetch that item usingModel.get()
it will return aPromise<T>
. Now your types won't match your object.Code sample:
Schema
Model
General
Current output and behavior (including stack trace):
Using the example from the docs, that
create
call won't cause any type errors.Expected output and behavior:
I believe this should cause a type error, because the Cat class contains a
name
field which is not optional andcreate
shouldn't allow you to pass in an invalid object.Environment:
Operating System: MacOS
Operating System Version: Sonama 14.4.1
Node.js version (
node -v
): 20.12.1NPM version: (
npm -v
): yarn 1.22.22Dynamoose version: 4.0.1
Other information (if applicable):
No other information.
Other:
The text was updated successfully, but these errors were encountered: