diff --git a/types/keyv/index.d.ts b/types/keyv/index.d.ts index 11e1895c9a..9d0e2c6404 100644 --- a/types/keyv/index.d.ts +++ b/types/keyv/index.d.ts @@ -10,9 +10,9 @@ interface KeyvOptions { /** Namespace for the current instance. */ namespace?: string; /** A custom serialization function. */ - serialize: (data: any) => string; + serialize?: (data: any) => string; /** A custom deserialization function. */ - deserialize: (data: string) => any; + deserialize?: (data: string) => any; /** The connection string URI. */ uri?: string; /** The storage adapter instance to be used by Keyv. */ @@ -24,6 +24,10 @@ interface KeyvOptions { } declare class Keyv extends NodeJS.EventEmitter { + /** + * @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options. + */ + constructor(opts?: KeyvOptions); /** * @param uri The connection string URI. * @@ -31,10 +35,6 @@ declare class Keyv extends NodeJS.EventEmitter { * @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options. */ constructor(uri?: string, opts?: KeyvOptions); - /** - * @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options. - */ - constructor(opts?: KeyvOptions); /** Returns the value. */ get(key: string): Promise; /** diff --git a/types/keyv/keyv-tests.ts b/types/keyv/keyv-tests.ts index fc0c2f3ff1..7ee4cac90e 100644 --- a/types/keyv/keyv-tests.ts +++ b/types/keyv/keyv-tests.ts @@ -1,5 +1,10 @@ import Keyv = require("keyv"); +new Keyv({ + uri: 'redis://user:pass@localhost:6379', + namespace: "redis" +}); + new Keyv('mongodb://user:pass@localhost:27017/dbname'); new Keyv('redis://user:pass@localhost:6379'); new Keyv('sqlite://path/to/database.sqlite');