diff --git a/src/common/parser/EscapeSequenceParser.test.ts b/src/common/parser/EscapeSequenceParser.test.ts index 6a1e20eff..a5d35de9b 100644 --- a/src/common/parser/EscapeSequenceParser.test.ts +++ b/src/common/parser/EscapeSequenceParser.test.ts @@ -3,14 +3,13 @@ * @license MIT */ -import { IDcsHandler, IParsingState, IParams } from 'common/parser/Types'; +import { IDcsHandler, IParsingState, IParams, ParamsArray } from 'common/parser/Types'; import { EscapeSequenceParser, TransitionTable, VT500_TRANSITION_TABLE } from 'common/parser/EscapeSequenceParser'; import * as chai from 'chai'; import { StringToUtf32, stringFromCodePoint } from 'common/input/TextDecoder'; import { ParserState } from 'common/parser/Constants'; import { Params } from 'common/parser/Params'; -type ParamsArray = (number | number[])[]; function r(a: number, b: number): string[] { let c = b - a; @@ -30,7 +29,7 @@ class TestEscapeSequenceParser extends EscapeSequenceParser { this._osc = value; } public get params(): ParamsArray { - return this._params.toArray() as ParamsArray; + return this._params.toArray(); } public set params(value: ParamsArray) { this._params = Params.fromArray(value); diff --git a/src/common/parser/Params.test.ts b/src/common/parser/Params.test.ts index 3278287e8..01287b8f7 100644 --- a/src/common/parser/Params.test.ts +++ b/src/common/parser/Params.test.ts @@ -4,6 +4,7 @@ */ import { assert } from 'chai'; import { Params } from 'common/parser/Params'; +import { ParamsArray } from 'common/parser/Types'; class TestParams extends Params { public get subParams(): Int32Array { @@ -108,7 +109,7 @@ describe('Params', () => { assert.deepEqual(params.toArray(), [1, [2, 3], 12345, [-1]]); }); it('Params.fromArray --> toArray', () => { - let data: (number | number[])[] = []; + let data: ParamsArray = []; assert.deepEqual(Params.fromArray(data).toArray(), data); data = [1, [2, 3], 12345, [-1]]; assert.deepEqual(Params.fromArray(data).toArray(), data); diff --git a/src/common/parser/Params.ts b/src/common/parser/Params.ts index 8a66a81aa..1ded5dcfc 100644 --- a/src/common/parser/Params.ts +++ b/src/common/parser/Params.ts @@ -2,7 +2,7 @@ * Copyright (c) 2019 The xterm.js authors. All rights reserved. * @license MIT */ -import { IParams } from 'common/parser/Types'; +import { IParams, ParamsArray } from 'common/parser/Types'; // max value supported for a single param/subparam (clamped to positive int32 range) const MAX_VALUE = 0x7FFFFFFF; @@ -57,7 +57,7 @@ export class Params implements IParams { /** * Create a `Params` type from JS array representation. */ - public static fromArray(values: (number | number[])[]): Params { + public static fromArray(values: ParamsArray): Params { const params = new Params(); if (!values.length) { return params; @@ -112,8 +112,8 @@ export class Params implements IParams { * sequence: "1;2:3:4;5::6" * array : [1, 2, [3, 4], 5, [-1, 6]] */ - public toArray(): (number | number[])[] { - const res: (number | number[])[] = []; + public toArray(): ParamsArray { + const res: ParamsArray = []; for (let i = 0; i < this.length; ++i) { res.push(this.params[i]); const start = this._subParamsIdx[i] >> 8; diff --git a/src/common/parser/Types.d.ts b/src/common/parser/Types.d.ts index 436c70af4..5f9256907 100644 --- a/src/common/parser/Types.d.ts +++ b/src/common/parser/Types.d.ts @@ -16,6 +16,8 @@ export interface IParamsConstructor { fromArray(values: (number | number[])[]): IParams; } +export type ParamsArray = (number | number[])[]; + export interface IParams { /** from ctor */ maxLength: number; @@ -27,7 +29,7 @@ export interface IParams { /** methods */ clone(): IParams; - toArray(): (number | number[])[]; + toArray(): ParamsArray; reset(): void; addParam(value: number): void; addSubParam(value: number): void;