Add explicit types on set/getOption
This commit is contained in:
+15
-4
@@ -29,7 +29,7 @@ import * as Mouse from './utils/Mouse';
|
||||
import { CHARSETS } from './Charsets';
|
||||
import { getRawByteCoords } from './utils/Mouse';
|
||||
import { translateBufferLineToString } from './utils/BufferLine';
|
||||
import { CustomKeyEventHandler, Charset, LinkMatcherHandler, LinkMatcherValidationCallback, CharData, LineData } from './Types';
|
||||
import { CustomKeyEventHandler, Charset, LinkMatcherHandler, LinkMatcherValidationCallback, CharData, LineData, Option, StringOption, BooleanOption, StringArrayOption, NumberOption, GeometryOption, HandlerOption } from './Types';
|
||||
import { ITerminal, IBrowser, ITerminalOptions, IInputHandlingTerminal, ILinkMatcherOptions } from './Interfaces';
|
||||
|
||||
// Declare for RequireJS in loadAddon
|
||||
@@ -415,7 +415,13 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
||||
* Retrieves an option's value from the terminal.
|
||||
* @param {string} key The option key.
|
||||
*/
|
||||
public getOption(key: string): any {
|
||||
public getOption(key: StringOption): string;
|
||||
public getOption(key: BooleanOption): boolean;
|
||||
public getOption(key: StringArrayOption): number[];
|
||||
public getOption(key: NumberOption): number;
|
||||
public getOption(key: GeometryOption): [number, number];
|
||||
public getOption(key: HandlerOption): (data: string) => void;
|
||||
public getOption(key: Option): any {
|
||||
if (!(key in DEFAULT_OPTIONS)) {
|
||||
throw new Error('No option with key "' + key + '"');
|
||||
}
|
||||
@@ -432,8 +438,13 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
||||
* @param {string} key The option key.
|
||||
* @param {any} value The option value.
|
||||
*/
|
||||
public setOption(key: string, value: any): void {
|
||||
// TODO: Give value a better type (boolean | string, ...)
|
||||
public setOption(key: StringOption, value: string): void;
|
||||
public setOption(key: BooleanOption, value: boolean): void;
|
||||
public setOption(key: StringArrayOption, value: number[]): void;
|
||||
public setOption(key: NumberOption, value: number): void;
|
||||
public setOption(key: GeometryOption, value: [number, number]): void;
|
||||
public setOption(key: HandlerOption, value: (data: string) => void): void;
|
||||
public setOption(key: Option, value: any): void {
|
||||
if (!(key in DEFAULT_OPTIONS)) {
|
||||
throw new Error('No option with key "' + key + '"');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user