[@keyv/redis] Add types (#31809)

This commit is contained in:
Dimitri Benin
2018-12-31 10:55:20 -08:00
committed by Sheetal Nandi
parent 56f95b3526
commit 8492d9a89b
4 changed files with 74 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
// Type definitions for @keyv/redis 1.3
// Project: https://github.com/lukechilds/keyv-redis
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
import { Store } from 'keyv';
import { ClientOpts } from 'redis';
import { EventEmitter } from 'events';
export = KeyvRedis;
declare class KeyvRedis extends EventEmitter implements Store<string | undefined> {
readonly ttlSupport: true;
namespace?: string;
constructor(options?: KeyvRedis.Options);
constructor(uri: string, options?: KeyvRedis.Options);
get(key: string): Promise<string | undefined>;
set(key: string, value: string | undefined, ttl?: number): Promise<number>;
delete(key: string): Promise<boolean>;
clear(): Promise<void>;
}
declare namespace KeyvRedis {
interface Options extends ClientOpts {
uri?: string;
}
}
+13
View File
@@ -0,0 +1,13 @@
import Keyv = require('keyv');
import KeyvRedis = require('@keyv/redis');
new Keyv('redis://user:pass@localhost:6379', { max_attempts: 1 });
new KeyvRedis({ uri: 'redis://user:pass@localhost:6379' });
new KeyvRedis('redis://user:pass@localhost:6379', { max_attempts: 1 });
new KeyvRedis('redis://user:pass@localhost:6379', {
uri: 'redis://user:pass@localhost:6379',
max_attempts: 1,
});
const redis = new KeyvRedis('redis://user:pass@localhost:6379');
new Keyv({ store: redis });
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"@keyv/redis": [
"keyv__redis"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"keyv__redis-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }