aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/ctx.ts
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-02 21:27:58 +0000
committerGitHub <[email protected]>2020-02-02 21:27:58 +0000
commitae16884b950d26546f323810170b1f8a25dc0bc0 (patch)
tree2b51c5ea7f7cbda460ea08c535a2f56489295543 /editors/code/src/ctx.ts
parent5e61c9b11def1897c4123eeafb14b4d6a5223546 (diff)
parent2fd7af2a62ce0c8acb5daa6b2c179b638318f31a (diff)
Merge #2989
2989: vscode extension: migrate from any to unknown where possible r=Veetaha a=Veetaha `unknown` type is the stricter version of `any` and it should always be prefered (like `const` over `let`). It lets you assign any value to it, but doesn't let you carry out arbitrary operations on them without an explicit type check (like `typeof unknownValue === 'string'`). Co-authored-by: Veetaha <[email protected]>
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r--editors/code/src/ctx.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 094566d09..05d21ae56 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -1,5 +1,6 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3
3import { Config } from './config'; 4import { Config } from './config';
4import { createClient } from './client'; 5import { createClient } from './client';
5 6
@@ -52,12 +53,12 @@ export class Ctx {
52 overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) { 53 overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) {
53 const defaultCmd = `default:${name}`; 54 const defaultCmd = `default:${name}`;
54 const override = factory(this); 55 const override = factory(this);
55 const original = (...args: any[]) => 56 const original = (...args: unknown[]) =>
56 vscode.commands.executeCommand(defaultCmd, ...args); 57 vscode.commands.executeCommand(defaultCmd, ...args);
57 try { 58 try {
58 const d = vscode.commands.registerCommand( 59 const d = vscode.commands.registerCommand(
59 name, 60 name,
60 async (...args: any[]) => { 61 async (...args: unknown[]) => {
61 if (!(await override(...args))) { 62 if (!(await override(...args))) {
62 return await original(...args); 63 return await original(...args);
63 } 64 }
@@ -73,11 +74,11 @@ export class Ctx {
73 } 74 }
74 } 75 }
75 76
76 get subscriptions(): { dispose(): any }[] { 77 get subscriptions(): Disposable[] {
77 return this.extCtx.subscriptions; 78 return this.extCtx.subscriptions;
78 } 79 }
79 80
80 pushCleanup(d: { dispose(): any }) { 81 pushCleanup(d: Disposable) {
81 this.extCtx.subscriptions.push(d); 82 this.extCtx.subscriptions.push(d);
82 } 83 }
83 84
@@ -86,12 +87,15 @@ export class Ctx {
86 } 87 }
87} 88}
88 89
89export type Cmd = (...args: any[]) => any; 90export interface Disposable {
91 dispose(): void;
92}
93export type Cmd = (...args: any[]) => unknown;
90 94
91export async function sendRequestWithRetry<R>( 95export async function sendRequestWithRetry<R>(
92 client: lc.LanguageClient, 96 client: lc.LanguageClient,
93 method: string, 97 method: string,
94 param: any, 98 param: unknown,
95 token?: vscode.CancellationToken, 99 token?: vscode.CancellationToken,
96): Promise<R> { 100): Promise<R> {
97 for (const delay of [2, 4, 6, 8, 10, null]) { 101 for (const delay of [2, 4, 6, 8, 10, null]) {