From 969ba41133e9f337a6eb5f71926965ec557a6e3b Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 3 Jun 2018 17:32:30 -0400 Subject: [PATCH] Removes some `as any` usages --- src/commands/common.ts | 6 +++--- src/system/array.ts | 2 +- src/trackers/activeEditorTracker.ts | 10 +++++----- src/views/gitExplorer.ts | 2 +- src/views/historyExplorer.ts | 2 +- src/views/resultsExplorer.ts | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/commands/common.ts b/src/commands/common.ts index ca45c94..d620ea7 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -134,11 +134,11 @@ export interface CommandViewContext extends CommandBaseContext { } export function isCommandViewContextWithBranch(context: CommandContext): context is CommandViewContext & { node: (ExplorerNode & { branch: GitBranch }) } { - return context.type === 'view' && (context.node as any).branch && (context.node as any).branch instanceof GitBranch; + return context.type === 'view' && (context.node as (ExplorerNode & { branch?: GitBranch })).branch instanceof GitBranch; } export function isCommandViewContextWithCommit(context: CommandContext): context is CommandViewContext & { node: (ExplorerNode & { commit: T }) } { - return context.type === 'view' && (context.node as any).commit && (context.node as any).commit instanceof GitCommit; + return context.type === 'view' && (context.node as (ExplorerNode & { commit?: GitCommit })).commit instanceof GitCommit; } export function isCommandViewContextWithRef(context: CommandContext): context is CommandViewContext & { node: (ExplorerNode & { ref: string }) } { @@ -146,7 +146,7 @@ export function isCommandViewContextWithRef(context: CommandContext): context is } export function isCommandViewContextWithRemote(context: CommandContext): context is CommandViewContext & { node: (ExplorerNode & { remote: GitRemote }) } { - return context.type === 'view' && (context.node as any).remote && (context.node as any).remote instanceof GitRemote; + return context.type === 'view' && (context.node as (ExplorerNode & { remote?: GitRemote })).remote instanceof GitRemote; } export type CommandContext = CommandScmGroupsContext | CommandScmStatesContext | CommandUnknownContext | CommandUriContext | CommandViewContext; diff --git a/src/system/array.ts b/src/system/array.ts index 7fd00f8..e118ad3 100644 --- a/src/system/array.ts +++ b/src/system/array.ts @@ -18,7 +18,7 @@ export namespace Arrays { accumulator.push(mapped); } return accumulator; - }, [] as any); + }, [] as TMapped[]); } export async function filterMapAsync(source: T[], predicateMapper: (item: T) => Promise): Promise { diff --git a/src/trackers/activeEditorTracker.ts b/src/trackers/activeEditorTracker.ts index 8f8c1df..3c946db 100644 --- a/src/trackers/activeEditorTracker.ts +++ b/src/trackers/activeEditorTracker.ts @@ -40,20 +40,20 @@ export class ActiveEditorTracker extends Disposable { async wait(timeout: number = 500): Promise { const editor = await new Promise((resolve, reject) => { - let timer: any; + let timer: NodeJS.Timer | undefined; this._resolver = (editor: TextEditor | undefined) => { if (timer) { - clearTimeout(timer as any); - timer = 0; + clearTimeout(timer); + timer = undefined; resolve(editor); } }; timer = setTimeout(() => { resolve(window.activeTextEditor); - timer = 0; - }, timeout) as any; + timer = undefined; + }, timeout); }); this._resolver = undefined; diff --git a/src/views/gitExplorer.ts b/src/views/gitExplorer.ts index 6d89e31..73e6bc0 100644 --- a/src/views/gitExplorer.ts +++ b/src/views/gitExplorer.ts @@ -212,7 +212,7 @@ export class GitExplorer extends Disposable implements TreeDataProvider