Archived
1
0

Some cleanup

- Use whateverEmitter.event for the onWhatever methods.
- Add readonly to a bunch of things.
- Remove some redundancy in types.
- Move initializations out of the constructor and into the declarations
  where it was reasonable to do so.
- Disable a few no-any violations.
This commit is contained in:
Asher
2019-02-06 11:53:23 -06:00
parent ddf96077a3
commit 588da0443c
16 changed files with 98 additions and 164 deletions

View File

@ -9,11 +9,10 @@ type nodePtyType = typeof nodePty;
* Implementation of nodePty for the browser.
*/
class Pty implements nodePty.IPty {
private readonly emitter: EventEmitter;
private readonly emitter = new EventEmitter();
private readonly cp: ChildProcess;
public constructor(file: string, args: string[] | string, options: nodePty.IPtyForkOptions) {
this.emitter = new EventEmitter();
this.cp = client.spawn(file, Array.isArray(args) ? args : [args], {
...options,
tty: {
@ -38,7 +37,8 @@ class Pty implements nodePty.IPty {
return this.cp.title!;
}
public on(event: string, listener: (...args) => void): void {
// tslint:disable-next-line no-any
public on(event: string, listener: (...args: any[]) => void): void {
this.emitter.on(event, listener);
}

View File

@ -4,11 +4,13 @@ import { IpcRenderer } from "electron";
export * from "@coder/ide/src/fill/electron";
class StdioIpcRenderer extends StdioIpcHandler implements IpcRenderer {
public sendTo(windowId: number, channel: string, ...args: any[]): void {
// tslint:disable-next-line no-any
public sendTo(_windowId: number, _channel: string, ..._args: any[]): void {
throw new Error("Method not implemented.");
}
public sendToHost(channel: string, ...args: any[]): void {
// tslint:disable-next-line no-any
public sendToHost(_channel: string, ..._args: any[]): void {
throw new Error("Method not implemented.");
}

View File

@ -10,7 +10,7 @@ import { logger, field } from "@coder/logger";
class StorageDatabase implements workspaceStorage.IStorageDatabase {
public readonly onDidChangeItemsExternal = Event.None;
private items = new Map<string, string>();
private readonly items = new Map<string, string>();
private fetched: boolean = false;
public constructor(private readonly path: string) {

View File

@ -17,21 +17,21 @@ class WindowsService implements IWindowsService {
// tslint:disable-next-line no-any
public _serviceBrand: any;
private openEmitter = new Emitter<number>();
private focusEmitter = new Emitter<number>();
private blurEmitter = new Emitter<number>();
private maximizeEmitter = new Emitter<number>();
private unmaximizeEmitter = new Emitter<number>();
private recentlyOpenedChangeEmitter = new Emitter<void>();
private readonly openEmitter = new Emitter<number>();
private readonly focusEmitter = new Emitter<number>();
private readonly blurEmitter = new Emitter<number>();
private readonly maximizeEmitter = new Emitter<number>();
private readonly unmaximizeEmitter = new Emitter<number>();
private readonly recentlyOpenedChangeEmitter = new Emitter<void>();
public onWindowOpen = this.openEmitter.event;
public onWindowFocus = this.focusEmitter.event;
public onWindowBlur = this.blurEmitter.event;
public onWindowMaximize = this.maximizeEmitter.event;
public onWindowUnmaximize = this.unmaximizeEmitter.event;
public onRecentlyOpenedChange = this.recentlyOpenedChangeEmitter.event;
public readonly onWindowOpen = this.openEmitter.event;
public readonly onWindowFocus = this.focusEmitter.event;
public readonly onWindowBlur = this.blurEmitter.event;
public readonly onWindowMaximize = this.maximizeEmitter.event;
public readonly onWindowUnmaximize = this.unmaximizeEmitter.event;
public readonly onRecentlyOpenedChange = this.recentlyOpenedChangeEmitter.event;
private window = new electron.BrowserWindow();
private readonly window = new electron.BrowserWindow();
// Dialogs
public pickFileFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {