Skip to content

Commit

Permalink
Add generic overloads to overloaded functions in d.ts
Browse files Browse the repository at this point in the history
If we don't have this then tsc will throw errors when passing strings
to the functions, seems wrong to force casting strings to use the
functions, eg. <'bar'>style
  • Loading branch information
Tyriar committed Aug 20, 2017
1 parent cea3dd6 commit 8bc2242
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion typings/xterm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,19 @@ declare module 'xterm' {
* @param listener The listener.
*/
on(type: 'title', listener: (title?: string) => void): void;
/**
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
*/
on(type: string, listener: (...args: any[]) => void): void;

/**
* Deregisters an event listener.
* @param type The type of the event.
* @param listener The listener.
*/
off(type: 'blur' | 'focus' | 'lineFeed' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title', listener: (...args: any[]) => void): void;
off(type: 'blur' | 'focus' | 'lineFeed' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title' | string, listener: (...args: any[]) => void): void;

/**
* Resizes the terminal.
Expand Down Expand Up @@ -333,6 +339,11 @@ declare module 'xterm' {
* @param key The option key.
*/
getOption(key: 'handler'): (data: string) => void;
/**
* Retrieves an option's value from the terminal.
* @param key The option key.
*/
getOption(key: string): any;

/**
* Sets an option on the terminal.
Expand Down Expand Up @@ -382,6 +393,12 @@ declare module 'xterm' {
* @param value The option value.
*/
setOption(key: 'handler', value: (data: string) => void): void;
/**
* Sets an option on the terminal.
* @param key The option key.
* @param value The option value.
*/
setOption(key: string, value: any): void;

/**
* Tells the renderer to refresh terminal content between two rows
Expand Down

0 comments on commit 8bc2242

Please sign in to comment.