-
Notifications
You must be signed in to change notification settings - Fork 109
Closed
Labels
api: datastoreIssues related to the googleapis/nodejs-datastore API.Issues related to the googleapis/nodejs-datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- OS: MacOS
- Node.js version: 16.15.0
- npm version: 8.5.5
@google-cloud/datastoreversion: 7.0.0
Steps to reproduce
Not sure if I'm missing something but currently any attempt to query by a value that might be null will result in TS error Type 'null' is not assignable to type '{}'.
e.g.
const queryByStatus = (status: string | null) => {
// Without operator
const query1 = datastore.createQuery(kind).filter("status", status);
// With operator
const query2 = datastore.createQuery(kind).filter("status", "=", status);
};
This is because the typings for Query.filter do not allow passing a null value:
filter(property: string, value: {}): Query;
filter(property: string, operator: Operator, value: {}): Query;
Note the workaround is to use the non-null operator ! on the value but this isn't ideal.
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the googleapis/nodejs-datastore API.Issues related to the googleapis/nodejs-datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.