Skip to content

Commit

Permalink
Remove simple to delete any references
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Jul 27, 2022
1 parent 8180561 commit baff98b
Show file tree
Hide file tree
Showing 60 changed files with 214 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface BulkEditNodeSelection {
bulkEdit: ResourceFileEdit | ResourceTextEdit;
}
export namespace BulkEditNodeSelection {
export function is(arg: Object | undefined): arg is BulkEditNodeSelection {
return typeof arg === 'object' && ('bulkEdit' in arg);
export function is(arg: unknown): arg is BulkEditNodeSelection {
return !!arg && typeof arg === 'object' && ('bulkEdit' in arg);
}

export class CommandHandler extends SelectionCommandHandler<BulkEditNodeSelection> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export interface BulkEditInfoNode extends UriSelection, SelectableTreeNode, Expa
fileContents?: string;
}
export namespace BulkEditInfoNode {
export function is(node: Object | undefined): node is BulkEditInfoNode {
export function is(node: unknown): node is BulkEditInfoNode {
return ExpandableTreeNode.is(node) && UriSelection.is(node) && 'fileContents' in node;
}
}
6 changes: 2 additions & 4 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1234,13 +1234,11 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
{
placeholder: nls.localizeByDefault('Select Color Theme (Up/Down Keys to Preview)'),
activeItem: items.find((item: QuickPickItem) => item.id === resetTo),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onDidChangeSelection: (quickPick: any, selectedItems: Array<QuickPickItem>) => {
onDidChangeSelection: (quickPick: QuickPick<QuickPickItem>, selectedItems: Array<QuickPickItem>) => {
resetTo = undefined;
previewTheme(selectedItems[0].id!);
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onDidChangeActive: (quickPick: any, activeItems: Array<QuickPickItem>) => {
onDidChangeActive: (quickPick: QuickPick<QuickPickItem>, activeItems: Array<QuickPickItem>) => {
previewTheme(activeItems[0].id!);
},
onDidHide: () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/browser/label-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ export interface URIIconReference {
uri?: URI
}
export namespace URIIconReference {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function is(element: any | undefined): element is URIIconReference {
return !!element && typeof element === 'object' && 'kind' in element && element['kind'] === 'uriIconReference';
export function is(element: unknown): element is URIIconReference {
return !!element && typeof element === 'object' && 'kind' in element && (element as URIIconReference).kind === 'uriIconReference';
}
export function create(id: URIIconReference['id'], uri?: URI): URIIconReference {
return { kind: 'uriIconReference', id, uri };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
// *****************************************************************************

/* eslint-disable @typescript-eslint/no-explicit-any */

import { inject, injectable } from 'inversify';
import { Menu } from '../widgets';
import { ContextMenuAccess, ContextMenuRenderer, coordinateFromAnchor, RenderContextMenuOptions } from '../context-menu-renderer';
Expand Down
11 changes: 5 additions & 6 deletions packages/core/src/browser/navigatable-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export interface Navigatable {
}

export namespace Navigatable {
export function is(arg: Object | undefined): arg is Navigatable {
return !!arg && 'getResourceUri' in arg && 'createMoveToUri' in arg;
export function is(arg: unknown): arg is Navigatable {
return !!arg && typeof arg === 'object' && 'getResourceUri' in arg && 'createMoveToUri' in arg;
}
}

export type NavigatableWidget = BaseWidget & Navigatable;
export namespace NavigatableWidget {
export function is(arg: Object | undefined): arg is NavigatableWidget {
export function is(arg: unknown): arg is NavigatableWidget {
return arg instanceof BaseWidget && Navigatable.is(arg);
}
export function* getAffected<T extends Widget>(
Expand Down Expand Up @@ -76,8 +76,7 @@ export interface NavigatableWidgetOptions {
counter?: number,
}
export namespace NavigatableWidgetOptions {
export function is(arg: Object | undefined): arg is NavigatableWidgetOptions {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return !!arg && 'kind' in arg && (arg as any).kind === 'navigatable';
export function is(arg: unknown): arg is NavigatableWidgetOptions {
return !!arg && typeof arg === 'object' && 'kind' in arg && (arg as NavigatableWidgetOptions).kind === 'navigatable';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class InjectablePreferenceProxy<T extends Record<string, JSONValue>> impl
if (this.schema && (this.isFlat || !property.includes('.')) && this.schema.properties[preferenceName]) {
const { overrideIdentifier } = this;
const toGet = overrideIdentifier ? this.preferences.overridePreferenceName({ overrideIdentifier, preferenceName }) : preferenceName;
return this.getValue(toGet as keyof T & string, undefined as any); // eslint-disable-line @typescript-eslint/no-explicit-any
return this.getValue(toGet as keyof T & string, undefined!);
}
switch (property) {
case 'onPreferenceChanged':
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/shell/application-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2059,8 +2059,8 @@ export namespace ApplicationShell {
}

export namespace TrackableWidgetProvider {
export function is(widget: object | undefined): widget is TrackableWidgetProvider {
return !!widget && 'getTrackableWidgets' in widget;
export function is(widget: unknown): widget is TrackableWidgetProvider {
return !!widget && typeof widget === 'object' && 'getTrackableWidgets' in widget;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ export namespace TabBarToolbarItem {
return (left.priority || 0) - (right.priority || 0);
};

export function is(arg: Object | undefined): arg is TabBarToolbarItem {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return !!arg && 'command' in arg && typeof (arg as any).command === 'string';
export function is(arg: unknown): arg is TabBarToolbarItem {
return !!arg && typeof arg === 'object' && 'command' in arg && typeof (arg as TabBarToolbarItem).command === 'string';
}

}
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/browser/shell/tab-bars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ export class TabBarRenderer extends TabBar.Renderer {
*/
protected getDecorations(title: Title<Widget>): WidgetDecoration.Data[] {
if (this.tabBar && this.decoratorService) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const owner: { resetTabBarDecorations?: () => void; } & Widget = title.owner;
if (!owner.resetTabBarDecorations) {
owner.resetTabBarDecorations = () => this.decorations.delete(title);
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/browser/shell/view-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export interface ViewContributionOptions {
toggleKeybinding?: string;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function bindViewContribution<T extends AbstractViewContribution<any>>(bind: interfaces.Bind, identifier: interfaces.Newable<T>): interfaces.BindingWhenOnSyntax<T> {
export function bindViewContribution<T extends AbstractViewContribution<Widget>>(bind: interfaces.Bind, identifier: interfaces.Newable<T>): interfaces.BindingWhenOnSyntax<T> {
const syntax = bind<T>(identifier).toSelf().inSingletonScope();
bind(CommandContribution).toService(identifier);
bind(KeybindingContribution).toService(identifier);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/tree/tree-expansion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ export namespace ExpandableTreeNode {
return !!node && CompositeTreeNode.is(node) && 'expanded' in node;
}

export function isExpanded(node: Object | undefined): node is ExpandableTreeNode {
export function isExpanded(node: unknown): node is ExpandableTreeNode {
return ExpandableTreeNode.is(node) && node.expanded;
}

export function isCollapsed(node: Object | undefined): node is ExpandableTreeNode {
export function isCollapsed(node: unknown): node is ExpandableTreeNode {
return ExpandableTreeNode.is(node) && !node.expanded;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/tree/tree-selection-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export namespace FocusableTreeSelection {
/**
* `true` if the argument is a focusable tree selection. Otherwise, `false`.
*/
export function is(arg: object | undefined): arg is FocusableTreeSelection {
export function is(arg: unknown): arg is FocusableTreeSelection {
return TreeSelection.is(arg) && 'focus' in arg;
}

Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/browser/tree/tree-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export namespace TreeSelection {
RANGE
}

export function is(arg: Object | undefined): arg is TreeSelection {
return !!arg && 'node' in arg;
export function is(arg: unknown): arg is TreeSelection {
return !!arg && typeof arg === 'object' && 'node' in arg;
}

export function isRange(arg: TreeSelection | SelectionType | undefined): boolean {
Expand Down Expand Up @@ -129,11 +129,11 @@ export interface SelectableTreeNode extends TreeNode {

export namespace SelectableTreeNode {

export function is(node: TreeNode | undefined): node is SelectableTreeNode {
return !!node && 'selected' in node;
export function is(node: unknown): node is SelectableTreeNode {
return TreeNode.is(node) && 'selected' in node;
}

export function isSelected(node: TreeNode | undefined): node is SelectableTreeNode {
export function isSelected(node: unknown): node is SelectableTreeNode {
return is(node) && node.selected;
}

Expand Down
9 changes: 4 additions & 5 deletions packages/core/src/browser/tree/tree-widget-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ export type TreeWidgetSelection = ReadonlyArray<Readonly<SelectableTreeNode>> &
source: TreeWidget
};
export namespace TreeWidgetSelection {
export function isSource(selection: Object | undefined, source: TreeWidget): selection is TreeWidgetSelection {
export function isSource(selection: unknown, source: TreeWidget): selection is TreeWidgetSelection {
return getSource(selection) === source;
}
export function getSource(selection: Object | undefined): TreeWidget | undefined {
export function getSource(selection: unknown): TreeWidget | undefined {
return is(selection) ? selection.source : undefined;
}
export function is(selection: Object | undefined): selection is TreeWidgetSelection {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return Array.isArray(selection) && ('source' in selection) && <any>selection['source'] instanceof TreeWidget;
export function is(selection: unknown): selection is TreeWidgetSelection {
return Array.isArray(selection) && ('source' in selection) && (selection as TreeWidgetSelection).source instanceof TreeWidget;
}

export function create(source: TreeWidget): TreeWidgetSelection {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export interface TreeNode {
}

export namespace TreeNode {
export function is(node: Object | undefined): node is TreeNode {
export function is(node: unknown): node is TreeNode {
return !!node && typeof node === 'object' && 'id' in node && 'parent' in node;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/view-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ export interface BadgeWidget {
}

export namespace DescriptionWidget {
export function is(arg: Object | undefined): arg is DescriptionWidget {
export function is(arg: unknown): arg is DescriptionWidget {
return !!arg && typeof arg === 'object' && 'onDidChangeDescription' in arg;
}
}

export namespace BadgeWidget {
export function is(arg: Object | undefined): arg is BadgeWidget {
export function is(arg: unknown): arg is BadgeWidget {
return !!arg && typeof arg === 'object' && 'onDidChangeBadge' in arg;
}
}
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/browser/widgets/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,8 @@ export interface EventListenerObject<K extends keyof HTMLElementEventMap> {
handleEvent(evt: HTMLElementEventMap[K]): void;
}
export namespace EventListenerObject {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function is<K extends keyof HTMLElementEventMap>(listener: any | undefined): listener is EventListenerObject<K> {
return !!listener && 'handleEvent' in listener;
export function is<K extends keyof HTMLElementEventMap>(listener: unknown): listener is EventListenerObject<K> {
return !!listener && typeof listener === 'object' && 'handleEvent' in listener;
}
}
export type EventListenerOrEventListenerObject<K extends keyof HTMLElementEventMap> = EventListener<K> | EventListenerObject<K>;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/preferences/preference-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export interface PreferenceSchema {
properties: PreferenceSchemaProperties
}
export namespace PreferenceSchema {
export function is(obj: Object | undefined): obj is PreferenceSchema {
return !!obj && ('properties' in obj) && PreferenceSchemaProperties.is((<any>obj)['properties']);
export function is(obj: unknown): obj is PreferenceSchema {
return !!obj && typeof obj === 'object' && ('properties' in obj) && PreferenceSchemaProperties.is((obj as PreferenceSchema).properties);
}
export function getDefaultScope(schema: PreferenceSchema): PreferenceScope {
let defaultScope: PreferenceScope = PreferenceScope.Workspace;
Expand Down
9 changes: 4 additions & 5 deletions packages/core/src/common/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ export interface UriSelection {

export namespace UriSelection {

export function is(arg: Object | undefined): arg is UriSelection {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return typeof arg === 'object' && ('uri' in arg) && (<any>arg)['uri'] instanceof URI;
export function is(arg: unknown): arg is UriSelection {
return !!arg && typeof arg === 'object' && ('uri' in arg) && (arg as UriSelection).uri instanceof URI;
}

export function getUri(selection: Object | undefined): URI | undefined {
export function getUri(selection: unknown): URI | undefined {
if (is(selection)) {
return selection.uri;
}
Expand All @@ -37,7 +36,7 @@ export namespace UriSelection {
return undefined;
}

export function getUris(selection: Object | undefined): URI[] {
export function getUris(selection: unknown): URI[] {
if (is(selection)) {
return [selection.uri];
}
Expand Down
4 changes: 2 additions & 2 deletions packages/debug/src/common/debug-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface DebugConfiguration {
* The data is sent as the 'restart' attribute of the 'terminated' event.
* The client should leave the data intact.
*/
__restart?: any;
__restart?: boolean;

/** default: neverOpen */
openDebug?: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart' | 'openOnDebugBreak';
Expand All @@ -71,7 +71,7 @@ export interface DebugConfiguration {
postDebugTask?: string | TaskIdentifier;
}
export namespace DebugConfiguration {
export function is(arg: DebugConfiguration | any): arg is DebugConfiguration {
export function is(arg: unknown): arg is DebugConfiguration {
return !!arg && typeof arg === 'object' && 'type' in arg && 'name' in arg && 'request' in arg;
}
}
Expand Down
5 changes: 2 additions & 3 deletions packages/debug/src/node/debug-adapter-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ export class LaunchBasedDebugAdapterFactory implements DebugAdapterFactory {
}

private childProcess(executable: DebugAdapterExecutable): RawProcess {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const isForkOptions = (forkOptions: RawForkOptions | any): forkOptions is RawForkOptions =>
!!forkOptions && !!forkOptions.modulePath;
const isForkOptions = (forkOptions: unknown): forkOptions is RawForkOptions =>
!!forkOptions && typeof forkOptions === 'object' && 'modulePath' in forkOptions;

const processOptions: RawProcessOptions | RawForkOptions = { ...executable };
const options: { stdio: (string | number)[], env?: object, execArgv?: string[] } = { stdio: ['pipe', 'pipe', 2] };
Expand Down
5 changes: 2 additions & 3 deletions packages/editor/src/browser/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,8 @@ export interface ReplaceOperation {
}

export namespace TextEditorSelection {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function is(e: any): e is TextEditorSelection {
return e && e['uri'] instanceof URI;
export function is(e: unknown): e is TextEditorSelection {
return !!e && typeof e === 'object' && (e as TextEditorSelection).uri instanceof URI;
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/filesystem/src/browser/file-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface FileSelection {
fileStat: FileStat
}
export namespace FileSelection {
export function is(arg: Object | undefined): arg is FileSelection {
return typeof arg === 'object' && ('fileStat' in arg) && FileStat.is(arg['fileStat']);
export function is(arg: unknown): arg is FileSelection {
return !!arg && typeof arg === 'object' && ('fileStat' in arg) && FileStat.is((arg as FileSelection).fileStat);
}
export class CommandHandler extends SelectionCommandHandler<FileSelection> {

Expand Down
12 changes: 6 additions & 6 deletions packages/filesystem/src/browser/file-tree/file-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export class FileTree extends TreeImpl {
export interface FileStatNode extends SelectableTreeNode, Mutable<UriSelection>, FileSelection {
}
export namespace FileStatNode {
export function is(node: object | undefined): node is FileStatNode {
return !!node && 'fileStat' in node;
export function is(node: unknown): node is FileStatNode {
return !!node && typeof node === 'object' && 'fileStat' in node;
}

export function getUri(node: TreeNode | undefined): string | undefined {
Expand All @@ -119,21 +119,21 @@ export type FileStatNodeData = Omit<FileStatNode, 'uri' | 'fileStat'> & {
fileStat?: FileStat
};
export namespace FileStatNodeData {
export function is(node: object | undefined): node is FileStatNodeData {
return !!node && 'uri' in node && ('fileStat' in node || 'stat' in node);
export function is(node: unknown): node is FileStatNodeData {
return !!node && typeof node === 'object' && 'uri' in node && ('fileStat' in node || 'stat' in node);
}
}

export type FileNode = FileStatNode;
export namespace FileNode {
export function is(node: Object | undefined): node is FileNode {
export function is(node: unknown): node is FileNode {
return FileStatNode.is(node) && !node.fileStat.isDirectory;
}
}

export type DirNode = FileStatNode & ExpandableTreeNode;
export namespace DirNode {
export function is(node: Object | undefined): node is DirNode {
export function is(node: unknown): node is DirNode {
return FileStatNode.is(node) && node.fileStat.isDirectory;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/filesystem/src/common/download/file-download-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface FileDownloadData {
}

export namespace FileDownloadData {
export function is(arg: Object | undefined): arg is FileDownloadData {
return !!arg && 'uris' in arg;
export function is(arg: unknown): arg is FileDownloadData {
return !!arg && typeof arg === 'object' && 'uris' in arg;
}
}
Loading

0 comments on commit baff98b

Please sign in to comment.