mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add redis-error types
This commit is contained in:
parent
b4855506d3
commit
df277f8016
33
types/redis-errors/index.d.ts
vendored
Normal file
33
types/redis-errors/index.d.ts
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// Type definitions for redis-errors 1.2
|
||||
// Project: https://github.com/NodeRedis/redis-errors#readme
|
||||
// Definitions by: James Garbutt <https://github.com/43081j>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export class RedisError extends Error {
|
||||
}
|
||||
|
||||
export class ParserError extends RedisError {
|
||||
buffer: string;
|
||||
offset: number;
|
||||
|
||||
constructor(message: string, buffer: string, offset: number);
|
||||
}
|
||||
|
||||
export class ReplyError extends RedisError {
|
||||
command?: string;
|
||||
args?: any[];
|
||||
code?: string;
|
||||
|
||||
constructor(message: string);
|
||||
}
|
||||
|
||||
export class AbortError extends RedisError {
|
||||
command?: string;
|
||||
args?: any[];
|
||||
}
|
||||
|
||||
export class InterruptError extends RedisError {
|
||||
command?: string;
|
||||
args?: any[];
|
||||
origin: Error;
|
||||
}
|
||||
27
types/redis-errors/redis-errors-tests.ts
Normal file
27
types/redis-errors/redis-errors-tests.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import {
|
||||
RedisError,
|
||||
ReplyError,
|
||||
ParserError,
|
||||
AbortError,
|
||||
InterruptError
|
||||
} from 'redis-errors';
|
||||
|
||||
const err = new RedisError('some error');
|
||||
|
||||
const reply = new ReplyError('some error');
|
||||
const replyArgs: any[] | undefined = reply.args;
|
||||
const replyCommand: string | undefined = reply.command;
|
||||
const replyCode: string | undefined = reply.code;
|
||||
|
||||
const parser = new ParserError('some error', 'a buffer', 4);
|
||||
const parserBuffer: string = parser.buffer;
|
||||
const parserOffset: number = parser.offset;
|
||||
|
||||
const abort = new AbortError('some error');
|
||||
const abortArgs: any[] | undefined = abort.args;
|
||||
const abortCommand: string | undefined = abort.command;
|
||||
|
||||
const interrupt = new InterruptError('some error');
|
||||
const interruptArgs: any[] | undefined = interrupt.args;
|
||||
const interruptCommand: string | undefined = interrupt.command;
|
||||
const interruptOrigin: Error | undefined = interrupt.origin;
|
||||
23
types/redis-errors/tsconfig.json
Normal file
23
types/redis-errors/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redis-errors-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/redis-errors/tslint.json
Normal file
1
types/redis-errors/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user