mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[couchbase]: Ensure OpCallback is composable with normal callbacks (#27639)
The documentation gets weird about the API promising to return *some* kind of value that evaluates to false, even if that might be the number zero. The original types author expressed that as CouchbaseError | number, but that makes it seem like the result could be some non-zero number. I don't know whether the library actually issues callback(0) calls, but to make it play better with normal callbacks (err?: Error), we will act as if it uses null instead of zero.
This commit is contained in:
parent
f8379fa8b0
commit
3f5b9e5f0e
@ -31,6 +31,11 @@ bucket.manager().createPrimaryIndex(function() {
|
||||
});
|
||||
});
|
||||
|
||||
// Ensure bucket.upsert is composable with normal callbacks
|
||||
function composable(callback: (err?: Error) => void) {
|
||||
bucket.upsert('key', {value: 1}, callback);
|
||||
}
|
||||
|
||||
// From https://developer.couchbase.com/documentation/server/current/sdk/nodejs/n1ql-queries-with-sdk.html
|
||||
function n1ql_a() {
|
||||
const n1qlquery = N1qlQuery.fromString('SELECT name, email FROM users WHERE name=$1');
|
||||
|
||||
4
types/couchbase/index.d.ts
vendored
4
types/couchbase/index.d.ts
vendored
@ -2019,10 +2019,10 @@ declare namespace Bucket {
|
||||
*/
|
||||
interface OpCallback {
|
||||
/**
|
||||
* @param error The error for the operation. This can either be an Error object or a value which evaluates to false (null, undefined, 0 or false).
|
||||
* @param error The error for the operation. This can either be an Error object or a value which evaluates to false.
|
||||
* @param result The result of the operation that was executed. This usually contains at least a cas property, and on some operations will contain a value property as well.
|
||||
*/
|
||||
(error: CouchbaseError | number, result: any): void;
|
||||
(error: CouchbaseError | null, result: any): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user