Add more complete type definitions for classes' methods

This commit is contained in:
Dirk Gadsden
2017-06-10 21:14:57 -07:00
parent e65b10905d
commit 0cdc06e03f
+12 -20
View File
@@ -5,7 +5,8 @@
declare namespace Hubot {
class Brain {
userForId: (id: any) => any;
userForId(id: any): any;
userForName(name: string): any;
}
class User {
@@ -22,33 +23,24 @@ declare namespace Hubot {
class Response {
match: RegExpMatchArray;
message: Message;
send: (...strings: string[]) => void;
reply: (...strings: string[]) => void;
random: <T>(items: T[]) => T;
constructor(robot: Robot, message: Message, match: RegExpMatchArray);
send(...strings: string[]): void;
reply(...strings: string[]): void;
random<T>(items: T[]): T;
}
interface ListenerCallback {
(response: Response): void;
}
interface HearWithOptions {
(regex: RegExp, options: any, callback: ListenerCallback): void;
}
interface HearWithoutOptions {
(regex: RegExp, callback: ListenerCallback): void;
}
interface RespondWithOptions {
(regex: RegExp, options: any, callback: ListenerCallback): void;
}
interface RespondWithoutOptions {
(regex: RegExp, callback: ListenerCallback): void;
}
export interface Robot {
brain: Brain;
hear: HearWithOptions & HearWithoutOptions;
respond: RespondWithOptions & RespondWithoutOptions;
hear(regex: RegExp, callback: ListenerCallback): void;
hear(regex: RegExp, options: any, callback: ListenerCallback): void;
response(regex: RegExp, callback: ListenerCallback): void;
response(regex: RegExp, options: any, callback: ListenerCallback): void;
}
}