From 57a198b08266473ab9053737a51d9721975d5ea6 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 14 Jul 2021 00:03:05 +0200 Subject: [PATCH] typing cleanup --- tabby-core/src/components/appRoot.component.ts | 2 +- tabby-core/src/components/startPage.component.ts | 2 +- tabby-core/src/components/tabHeader.component.ts | 2 +- tabby-core/src/components/windowControls.component.ts | 2 +- tabby-core/src/index.ts | 2 +- tabby-core/src/services/hotkeys.service.ts | 2 +- tabby-electron/src/services/platform.service.ts | 6 +++--- tabby-local/src/index.ts | 4 ++-- tabby-local/src/services/dockMenu.service.ts | 2 +- tabby-local/src/session.ts | 2 +- tabby-ssh/src/api.ts | 2 +- tabby-ssh/src/services/ssh.service.ts | 2 +- tabby-terminal/src/api/streamProcessing.ts | 2 +- tabby-terminal/src/frontends/xtermFrontend.ts | 8 ++++++-- tabby-terminal/src/index.ts | 4 ++-- tabby-web-demo/src/index.ts | 6 +++--- 16 files changed, 27 insertions(+), 23 deletions(-) diff --git a/tabby-core/src/components/appRoot.component.ts b/tabby-core/src/components/appRoot.component.ts index 92972cac..ca007f4b 100644 --- a/tabby-core/src/components/appRoot.component.ts +++ b/tabby-core/src/components/appRoot.component.ts @@ -64,7 +64,7 @@ export class AppRootComponent { activeTransfersDropdownOpen = false private logger: Logger - private constructor ( + constructor ( private hotkeys: HotkeysService, private updater: UpdaterService, public hostWindow: HostWindowService, diff --git a/tabby-core/src/components/startPage.component.ts b/tabby-core/src/components/startPage.component.ts index 3e22598c..e81ad811 100644 --- a/tabby-core/src/components/startPage.component.ts +++ b/tabby-core/src/components/startPage.component.ts @@ -13,7 +13,7 @@ import { ToolbarButton, ToolbarButtonProvider } from '../api' export class StartPageComponent { version: string - private constructor ( + constructor ( private config: ConfigService, private domSanitizer: DomSanitizer, public homeBase: HomeBaseService, diff --git a/tabby-core/src/components/tabHeader.component.ts b/tabby-core/src/components/tabHeader.component.ts index 3e52352b..89ffe23f 100644 --- a/tabby-core/src/components/tabHeader.component.ts +++ b/tabby-core/src/components/tabHeader.component.ts @@ -31,7 +31,7 @@ export class TabHeaderComponent extends BaseComponent { @Input() progress: number|null @ViewChild('handle') handle?: ElementRef - private constructor ( + constructor ( public app: AppService, public config: ConfigService, private hostApp: HostAppService, diff --git a/tabby-core/src/components/windowControls.component.ts b/tabby-core/src/components/windowControls.component.ts index 1889c87c..f6f511f1 100644 --- a/tabby-core/src/components/windowControls.component.ts +++ b/tabby-core/src/components/windowControls.component.ts @@ -10,7 +10,7 @@ import { AppService } from '../services/app.service' styles: [require('./windowControls.component.scss')], }) export class WindowControlsComponent { - private constructor (public hostWindow: HostWindowService, public app: AppService) { } + constructor (public hostWindow: HostWindowService, public app: AppService) { } async closeWindow () { this.app.closeWindow() diff --git a/tabby-core/src/index.ts b/tabby-core/src/index.ts index d3e38b7c..65e88190 100644 --- a/tabby-core/src/index.ts +++ b/tabby-core/src/index.ts @@ -81,7 +81,7 @@ const PROVIDERS = [ SortablejsModule.forRoot({ animation: 150 }), ], declarations: [ - AppRootComponent as any, + AppRootComponent, CheckboxComponent, PromptModalComponent, StartPageComponent, diff --git a/tabby-core/src/services/hotkeys.service.ts b/tabby-core/src/services/hotkeys.service.ts index 28a0118e..671178b2 100644 --- a/tabby-core/src/services/hotkeys.service.ts +++ b/tabby-core/src/services/hotkeys.service.ts @@ -63,7 +63,7 @@ export class HotkeysService { * @param nativeEvent event object */ pushKeystroke (name: string, nativeEvent: KeyboardEvent): void { - (nativeEvent as any).event = name + nativeEvent['event'] = name this.currentKeystrokes.push({ ctrlKey: nativeEvent.ctrlKey, metaKey: nativeEvent.metaKey, diff --git a/tabby-electron/src/services/platform.service.ts b/tabby-electron/src/services/platform.service.ts index ea78b668..5d93f8bc 100644 --- a/tabby-electron/src/services/platform.service.ts +++ b/tabby-electron/src/services/platform.service.ts @@ -2,7 +2,7 @@ import * as path from 'path' import * as fs from 'fs/promises' import * as fsSync from 'fs' import * as os from 'os' -import promiseIpc from 'electron-promise-ipc' +import promiseIpc, { RendererProcessType } from 'electron-promise-ipc' import { execFile } from 'mz/child_process' import { Injectable, NgZone } from '@angular/core' import { PlatformService, ClipboardContent, HostAppService, Platform, MenuItemOptions, MessageBoxOptions, MessageBoxResult, FileUpload, FileDownload, FileUploadOptions, wrapPromise } from 'tabby-core' @@ -49,11 +49,11 @@ export class ElectronPlatformService extends PlatformService { } async installPlugin (name: string, version: string): Promise { - await (promiseIpc as any).send('plugin-manager:install', name, version) + await (promiseIpc as RendererProcessType).send('plugin-manager:install', name, version) } async uninstallPlugin (name: string): Promise { - await (promiseIpc as any).send('plugin-manager:uninstall', name) + await (promiseIpc as RendererProcessType).send('plugin-manager:uninstall', name) } async isProcessRunning (name: string): Promise { diff --git a/tabby-local/src/index.ts b/tabby-local/src/index.ts index 3ba73402..a2dc985f 100644 --- a/tabby-local/src/index.ts +++ b/tabby-local/src/index.ts @@ -91,13 +91,13 @@ import { LocalProfilesService } from './profiles' TerminalTabComponent, ShellSettingsTabComponent, LocalProfileSettingsComponent, - ] as any[], + ], declarations: [ TerminalTabComponent, ShellSettingsTabComponent, EnvironmentEditorComponent, LocalProfileSettingsComponent, - ] as any[], + ], exports: [ TerminalTabComponent, EnvironmentEditorComponent, diff --git a/tabby-local/src/services/dockMenu.service.ts b/tabby-local/src/services/dockMenu.service.ts index 19046253..2845b43b 100644 --- a/tabby-local/src/services/dockMenu.service.ts +++ b/tabby-local/src/services/dockMenu.service.ts @@ -30,7 +30,7 @@ export class DockMenuService { iconPath: process.execPath, iconIndex: 0, })), - }] : null as any) + }] : null) } if (this.hostApp.platform === Platform.macOS) { this.electron.app.dock.setMenu(this.electron.Menu.buildFromTemplate( diff --git a/tabby-local/src/session.ts b/tabby-local/src/session.ts index 61ccad91..fd165245 100644 --- a/tabby-local/src/session.ts +++ b/tabby-local/src/session.ts @@ -160,7 +160,7 @@ export class Session extends BaseSession { cwd, env: env, // `1` instead of `true` forces ConPTY even if unstable - useConpty: (isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED) && this.config.store.terminal.useConPTY ? 1 : false) as any, + useConpty: isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED) && this.config.store.terminal.useConPTY ? 1 : false, }) this.guessedCWD = cwd ?? null diff --git a/tabby-ssh/src/api.ts b/tabby-ssh/src/api.ts index dda3243c..3072fbc6 100644 --- a/tabby-ssh/src/api.ts +++ b/tabby-ssh/src/api.ts @@ -471,7 +471,7 @@ export class SSHSession extends BaseSession { this.logger.info(stripAnsi(msg)) } - async handleAuth (methodsLeft?: string[]): Promise { + async handleAuth (methodsLeft?: string[] | null): Promise { this.activePrivateKey = null while (true) { diff --git a/tabby-ssh/src/services/ssh.service.ts b/tabby-ssh/src/services/ssh.service.ts index ab24eb05..1ae34bf2 100644 --- a/tabby-ssh/src/services/ssh.service.ts +++ b/tabby-ssh/src/services/ssh.service.ts @@ -146,7 +146,7 @@ export class SSHService { callback(await session.handleAuth(methodsLeft)) }) }, - } as any) + }) } catch (e) { this.notifications.error(e.message) throw e diff --git a/tabby-terminal/src/api/streamProcessing.ts b/tabby-terminal/src/api/streamProcessing.ts index d663c422..ff86942d 100644 --- a/tabby-terminal/src/api/streamProcessing.ts +++ b/tabby-terminal/src/api/streamProcessing.ts @@ -49,7 +49,7 @@ export class TerminalStreamProcessor { output: this.inputReadlineOutStream, terminal: true, prompt: this.options.inputMode === 'readline-hex' ? 'hex> ' : '> ', - } as any) + }) this.inputReadline.on('line', line => { this.onTerminalInput(Buffer.from(line + '\n')) this.resetInputPrompt() diff --git a/tabby-terminal/src/frontends/xtermFrontend.ts b/tabby-terminal/src/frontends/xtermFrontend.ts index ba20d8d3..e46017d5 100644 --- a/tabby-terminal/src/frontends/xtermFrontend.ts +++ b/tabby-terminal/src/frontends/xtermFrontend.ts @@ -56,7 +56,7 @@ export class XTermFrontend extends Frontend { allowTransparency: true, windowsMode: process.platform === 'win32', }) - this.xtermCore = (this.xterm as any)._core + this.xtermCore = this.xterm['_core'] this.xterm.onBinary(data => { this.input.next(Buffer.from(data, 'binary')) @@ -365,7 +365,11 @@ export class XTermFrontend extends Frontend { private getLineAsHTML (y: number, start: number, end: number): string { let html = '
' let lastStyle: string|null = null - const line = (this.xterm.buffer.active.getLine(y) as any)._line + const outerLine = this.xterm.buffer.active.getLine(y) + if (!outerLine) { + return '' + } + const line = outerLine['_line'] const cell = new CellData() for (let i = start; i < end; i++) { line.loadCell(i, cell) diff --git a/tabby-terminal/src/index.ts b/tabby-terminal/src/index.ts index 902995a3..1f7d9793 100644 --- a/tabby-terminal/src/index.ts +++ b/tabby-terminal/src/index.ts @@ -64,7 +64,7 @@ import { TerminalCLIHandler } from './cli' AppearanceSettingsTabComponent, ColorSchemeSettingsTabComponent, TerminalSettingsTabComponent, - ] as any[], + ], declarations: [ ColorPickerComponent, ColorSchemePreviewComponent, @@ -74,7 +74,7 @@ import { TerminalCLIHandler } from './cli' SearchPanelComponent, StreamProcessingSettingsComponent, LoginScriptsSettingsComponent, - ] as any[], + ], exports: [ ColorPickerComponent, SearchPanelComponent, diff --git a/tabby-web-demo/src/index.ts b/tabby-web-demo/src/index.ts index d2ee5ef4..430a9e5d 100644 --- a/tabby-web-demo/src/index.ts +++ b/tabby-web-demo/src/index.ts @@ -16,17 +16,17 @@ import { DemoProfilesService } from 'profiles' FormsModule, NgbModule, TabbyCorePlugin, - TabbyTerminalModule as any, + TabbyTerminalModule, ], providers: [ { provide: ProfileProvider, useClass: DemoProfilesService, multi: true }, ], entryComponents: [ DemoTerminalTabComponent, - ] as any[], + ], declarations: [ DemoTerminalTabComponent, - ] as any[], + ], exports: [ DemoTerminalTabComponent, ],