Skip to content

Commit

Permalink
fix type test fails caused by strict: true
Browse files Browse the repository at this point in the history
  • Loading branch information
tranhl committed Apr 25, 2024
1 parent e17bcdd commit 6859485
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions packages/dynamoose/test/types/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ const shouldFailWithInvalidConditionTransaction = model.transaction.condition(0,

// Typed Models
export class User extends Item {
id: string;
name: string;
age: number;
id!: string;
name!: string;
age!: number;
}
const userSchema = new dynamoose.Schema({
"id": String,
Expand Down Expand Up @@ -108,5 +108,5 @@ UserTypedModel.update({"id": "foo"}, {
});

UserTypedModel.update({"id": "foo"}, {
"$REMOVE":{"age":null}
"$REMOVE":{"age":undefined}
});
2 changes: 1 addition & 1 deletion packages/dynamoose/test/types/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const shouldSucceedWithAsyncSetMethodSchema = new dynamoose.Schema({
const shouldSucceedWithSetMethodSecondArgSchema = new dynamoose.Schema({
"id": {
"type": String,
"set": (value, oldValue) => oldValue
"set": (value, oldValue) => oldValue ? oldValue : value
}
});
const shouldSucceedWithAsyncValidateMethodSchema = new dynamoose.Schema({
Expand Down
7 changes: 5 additions & 2 deletions packages/dynamoose/test/types/model/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ let isAssignableToQuery : Query<User>;
isAssignableToQuery = UserTypedModel.query("name").eq("Will").limit(5);

// query.startAt(key)
async function queryStartAt (): Promise<Query<User>> {
async function queryStartAt (): Promise<Query<User> | undefined> {
const response = await UserTypedModel.query("name").eq("Will").exec();
return UserTypedModel.query("name").eq("Will").startAt(response.lastKey);

if (response.lastKey) {
return UserTypedModel.query("name").eq("Will").startAt(response.lastKey);
}
}

// query.attributes(attributes)
Expand Down
6 changes: 4 additions & 2 deletions packages/dynamoose/test/types/model/Scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ let isAssignableToScan : Scan<User>;
isAssignableToScan = UserTypedModel.scan().limit(5);

// scan.startAt(key)
async function scanStartAt (): Promise<Scan<User>> {
async function scanStartAt (): Promise<Scan<User> | undefined> {
const response = await UserTypedModel.scan().exec();
return UserTypedModel.scan().startAt(response.lastKey);
if (response.lastKey) {
return UserTypedModel.scan().startAt(response.lastKey);
}
}

// scan.attributes(attributes)
Expand Down
2 changes: 1 addition & 1 deletion packages/dynamoose/test/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"target": "es2017",
"noEmit": true,
"strict": true
},
},
"include": ["./**/*"]
}

0 comments on commit 6859485

Please sign in to comment.