mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Expand hubot typings (#34916)
* Expand hubot typings * Fix build issue * Fix tests for mattvperrys hubot pr * Update mattvperrys code after rebase * Remove redundant line
This commit is contained in:
parent
f429a76527
commit
ed5fcefc9c
@ -1,9 +1,5 @@
|
||||
import * as Hubot from "hubot";
|
||||
|
||||
const brain = new Hubot.Brain();
|
||||
brain; // $ExpectType Brain
|
||||
brain.userForName('someone'); // $ExpectType any
|
||||
|
||||
const robot = new Hubot.Robot<{}>(
|
||||
'src/adapters',
|
||||
'slack',
|
||||
@ -13,3 +9,11 @@ const robot = new Hubot.Robot<{}>(
|
||||
robot; // $ExpectType Robot<{}>
|
||||
robot.adapter; // $ExpectType {}
|
||||
robot.hear(/hello/, () => null); // $ExpectType void
|
||||
robot.on('test', () => null); // $ExpectType Robot<{}>
|
||||
robot.emit('test', 'arg'); // $ExpectType boolean
|
||||
|
||||
const brain = new Hubot.Brain(robot);
|
||||
brain; // $ExpectType Brain<{}>
|
||||
brain.userForName('someone'); // $ExpectType User
|
||||
brain.get('test'); // $ExpectType any
|
||||
brain.set('test', 'test'); // $ExpectType Brain<{}>
|
||||
|
||||
39
types/hubot/index.d.ts
vendored
39
types/hubot/index.d.ts
vendored
@ -4,22 +4,43 @@
|
||||
// Kees C. Bakker <https://github.com/KeesCBakker>
|
||||
// Emil Marklund <https://github.com/eeemil>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
declare namespace Hubot {
|
||||
class Brain {
|
||||
userForId(id: any): any;
|
||||
userForName(name: string): any;
|
||||
class Brain<A> extends EventEmitter {
|
||||
constructor(robot: Robot<A>);
|
||||
set(key: string, value: any): this;
|
||||
get(key: string): any;
|
||||
remove(key: string): this;
|
||||
save(): void;
|
||||
close(): void;
|
||||
setAutoSave(enabled: boolean): void;
|
||||
resetSaveInterval(seconds: number): void;
|
||||
mergeData(data: any): void;
|
||||
users(): User[];
|
||||
userForId(id: any): User;
|
||||
userForName(name: string): User;
|
||||
userForRawFuzzyName(fuzzyName: string): User;
|
||||
userForFuzzyName(fuzzyName: string): User;
|
||||
}
|
||||
|
||||
class User {
|
||||
constructor(id: any, options?: any);
|
||||
id: any;
|
||||
name: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
class Message {
|
||||
constructor(user: User, done?: boolean)
|
||||
user: User;
|
||||
text: string;
|
||||
id: string;
|
||||
finish(): void;
|
||||
}
|
||||
|
||||
class Response<R> {
|
||||
@ -28,7 +49,11 @@ declare namespace Hubot {
|
||||
|
||||
constructor(robot: R, message: Message, match: RegExpMatchArray);
|
||||
send(...strings: string[]): void;
|
||||
emote(...strings: string[]): void;
|
||||
reply(...strings: string[]): void;
|
||||
topic(...strings: string[]): void;
|
||||
play(...strings: string[]): void;
|
||||
locked(...strings: string[]): void;
|
||||
random<T>(items: T[]): T;
|
||||
}
|
||||
|
||||
@ -36,7 +61,7 @@ declare namespace Hubot {
|
||||
|
||||
class Robot<A> {
|
||||
alias: string;
|
||||
brain: Brain;
|
||||
brain: Brain<A>;
|
||||
name: string;
|
||||
readonly adapter: A;
|
||||
|
||||
@ -49,6 +74,12 @@ declare namespace Hubot {
|
||||
loadFile(directory: string, fileName: string): void;
|
||||
respond(regex: RegExp, callback: ListenerCallback<this>): void;
|
||||
respond(regex: RegExp, options: any, callback: ListenerCallback<this>): void;
|
||||
enter(callback: ListenerCallback<this>): void;
|
||||
enter(options: any, callback: ListenerCallback<this>): void;
|
||||
topic(callback: ListenerCallback<this>): void;
|
||||
topic(options: any, callback: ListenerCallback<this>): void;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user