From 12d0970f7e4c4d7f91cccb12525fceea3c4c0669 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 22:19:59 +0200 Subject: vscode extension: migrate from any to unknown where possible --- editors/code/src/client.ts | 2 +- editors/code/src/color_theme.ts | 2 +- editors/code/src/commands/syntax_tree.ts | 2 +- editors/code/src/ctx.ts | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'editors') diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 15e1a0873..1778c4e9f 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -68,7 +68,7 @@ PATH=${process.env.PATH} // This also requires considering our settings strategy, which is work which needs doing // @ts-ignore The tracer is private to vscode-languageclient, but we need access to it to not log publishDecorations requests res._tracer = { - log: (messageOrDataObject: string | any, data?: string) => { + log: (messageOrDataObject: string | unknown, data?: string) => { if (typeof messageOrDataObject === 'string') { if ( messageOrDataObject.includes( diff --git a/editors/code/src/color_theme.ts b/editors/code/src/color_theme.ts index 71113d374..7e10c7f79 100644 --- a/editors/code/src/color_theme.ts +++ b/editors/code/src/color_theme.ts @@ -61,7 +61,7 @@ export class ColorTheme { } function loadThemeNamed(themeName: string): ColorTheme { - function isTheme(extension: vscode.Extension): boolean { + function isTheme(extension: vscode.Extension): boolean { return ( extension.extensionKind === vscode.ExtensionKind.UI && extension.packageJSON.contributes && diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts index 02ea9f166..562df50cd 100644 --- a/editors/code/src/commands/syntax_tree.ts +++ b/editors/code/src/commands/syntax_tree.ts @@ -55,7 +55,7 @@ export function syntaxTree(ctx: Ctx): Cmd { // We need to order this after LS updates, but there's no API for that. // Hence, good old setTimeout. -function afterLs(f: () => any) { +function afterLs(f: () => unknown) { setTimeout(f, 10); } diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 094566d09..aae2c5f90 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -52,12 +52,12 @@ export class Ctx { overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) { const defaultCmd = `default:${name}`; const override = factory(this); - const original = (...args: any[]) => + const original = (...args: unknown[]) => vscode.commands.executeCommand(defaultCmd, ...args); try { const d = vscode.commands.registerCommand( name, - async (...args: any[]) => { + async (...args: unknown[]) => { if (!(await override(...args))) { return await original(...args); } @@ -73,11 +73,11 @@ export class Ctx { } } - get subscriptions(): { dispose(): any }[] { + get subscriptions(): { dispose(): unknown }[] { return this.extCtx.subscriptions; } - pushCleanup(d: { dispose(): any }) { + pushCleanup(d: { dispose(): unknown }) { this.extCtx.subscriptions.push(d); } @@ -86,12 +86,12 @@ export class Ctx { } } -export type Cmd = (...args: any[]) => any; +export type Cmd = (...args: unknown[]) => unknown; export async function sendRequestWithRetry( client: lc.LanguageClient, method: string, - param: any, + param: unknown, token?: vscode.CancellationToken, ): Promise { for (const delay of [2, 4, 6, 8, 10, null]) { -- cgit v1.2.3 From 5411d65a7f8b86da46aeef23bb2c707408766135 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 22:36:12 +0200 Subject: vscode: fix, fallback to any for cmd type --- editors/code/src/ctx.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editors') diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index aae2c5f90..2d703af58 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -86,7 +86,7 @@ export class Ctx { } } -export type Cmd = (...args: unknown[]) => unknown; +export type Cmd = (...args: any[]) => unknown; export async function sendRequestWithRetry( client: lc.LanguageClient, -- cgit v1.2.3 From 2fd7af2a62ce0c8acb5daa6b2c179b638318f31a Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 2 Feb 2020 23:23:01 +0200 Subject: vscode: use void where possible --- editors/code/src/commands/syntax_tree.ts | 2 +- editors/code/src/ctx.ts | 8 ++++++-- editors/code/src/status_display.ts | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'editors') diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts index 562df50cd..211f2251f 100644 --- a/editors/code/src/commands/syntax_tree.ts +++ b/editors/code/src/commands/syntax_tree.ts @@ -55,7 +55,7 @@ export function syntaxTree(ctx: Ctx): Cmd { // We need to order this after LS updates, but there's no API for that. // Hence, good old setTimeout. -function afterLs(f: () => unknown) { +function afterLs(f: () => void) { setTimeout(f, 10); } diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 2d703af58..05d21ae56 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -1,5 +1,6 @@ import * as vscode from 'vscode'; import * as lc from 'vscode-languageclient'; + import { Config } from './config'; import { createClient } from './client'; @@ -73,11 +74,11 @@ export class Ctx { } } - get subscriptions(): { dispose(): unknown }[] { + get subscriptions(): Disposable[] { return this.extCtx.subscriptions; } - pushCleanup(d: { dispose(): unknown }) { + pushCleanup(d: Disposable) { this.extCtx.subscriptions.push(d); } @@ -86,6 +87,9 @@ export class Ctx { } } +export interface Disposable { + dispose(): void; +} export type Cmd = (...args: any[]) => unknown; export async function sendRequestWithRetry( diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts index 7345bc3f5..4317410c7 100644 --- a/editors/code/src/status_display.ts +++ b/editors/code/src/status_display.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; -import { WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd } from 'vscode-languageclient'; +import { WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd, Disposable } from 'vscode-languageclient'; import { Ctx } from './ctx'; @@ -14,7 +14,7 @@ export function activateStatusDisplay(ctx: Ctx) { }); } -class StatusDisplay implements vscode.Disposable { +class StatusDisplay implements vscode.Disposable, Disposable { packageName?: string; private i: number = 0; -- cgit v1.2.3