不要怂,就是干,撸起袖子干!

Commit 2bf7f7bb by Sebastian Di Luzio Committed by GitHub

fix(typings): add support for optional values in "where" clauses (#12337)

1 parent 65a9e1ea
Showing with 13 additions and 2 deletions
......@@ -339,8 +339,10 @@ export type WhereValue =
| OrOperator
| AndOperator
| WhereGeometryOptions
| (string | number | Buffer | WhereAttributeHash)[]; // implicit [Op.or]
| (string | number | Buffer | WhereAttributeHash)[] // implicit [Op.or]
// allow optional values in where object types
// Sequelize will still throw when a value in the object has the value undefined
| undefined;
/**
* A hash of attributes to describe your search.
*/
......
......@@ -25,6 +25,15 @@ where = {
date: new Date()
};
// Optional values
let whereWithOptionals: { needed: number; optional?: number } = { needed: 2 };
where = whereWithOptionals;
// Misusing optional values (typings allow this, sequelize will throw an error during runtime)
// This might be solved by updates to typescript itself (https://github.com/microsoft/TypeScript/issues/13195)
whereWithOptionals = { needed: 2, optional: undefined };
where = whereWithOptionals;
// Operators
const and: AndOperator = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!