@@ -26,9 +26,11 @@ interface ICommandOptions {
26
26
27
27
type ArgumentTransformer = ( args : any [ ] ) => any [ ] ;
28
28
type ReplyTransformer = ( reply : any ) => any ;
29
- type FlagMap = { [ flag : string ] : { [ command : string ] : true } } ;
29
+ interface IFlagMap {
30
+ [ flag : string ] : { [ command : string ] : true } ;
31
+ }
30
32
31
- export type CommandNameFlags = {
33
+ export interface ICommandNameFlags {
32
34
// Commands that can be processed when client is in the subscriber mode
33
35
VALID_IN_SUBSCRIBER_MODE : [
34
36
"subscribe" ,
@@ -46,7 +48,7 @@ export type CommandNameFlags = {
46
48
EXIT_SUBSCRIBER_MODE : [ "unsubscribe" , "punsubscribe" ] ;
47
49
// Commands that will make client disconnect from server TODO shutdown?
48
50
WILL_DISCONNECT : [ "quit" ] ;
49
- } ;
51
+ }
50
52
51
53
/**
52
54
* Command instance
@@ -75,7 +77,7 @@ export type CommandNameFlags = {
75
77
*/
76
78
export default class Command implements ICommand {
77
79
public static FLAGS : {
78
- [ key in keyof CommandNameFlags ] : CommandNameFlags [ key ] ;
80
+ [ key in keyof ICommandNameFlags ] : ICommandNameFlags [ key ] ;
79
81
} = {
80
82
VALID_IN_SUBSCRIBER_MODE : [
81
83
"subscribe" ,
@@ -91,9 +93,9 @@ export default class Command implements ICommand {
91
93
WILL_DISCONNECT : [ "quit" ]
92
94
} ;
93
95
94
- private static flagMap ?: FlagMap ;
96
+ private static flagMap ?: IFlagMap ;
95
97
96
- private static getFlagMap ( ) : FlagMap {
98
+ private static getFlagMap ( ) : IFlagMap {
97
99
if ( ! this . flagMap ) {
98
100
this . flagMap = Object . keys ( Command . FLAGS ) . reduce ( ( map , flagName ) => {
99
101
map [ flagName ] = { } ;
@@ -113,10 +115,10 @@ export default class Command implements ICommand {
113
115
* @param {string } commandName
114
116
* @return {boolean }
115
117
*/
116
- public static checkFlag < T extends keyof CommandNameFlags > (
118
+ public static checkFlag < T extends keyof ICommandNameFlags > (
117
119
flagName : T ,
118
120
commandName : string
119
- ) : commandName is CommandNameFlags [ T ] [ number ] {
121
+ ) : commandName is ICommandNameFlags [ T ] [ number ] {
120
122
return ! ! this . getFlagMap ( ) [ flagName ] [ commandName ] ;
121
123
}
122
124
0 commit comments