From a34e8f0e162765637744476aa994b5c941e33acc Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Mon, 11 Dec 2023 11:21:00 -0500 Subject: [PATCH] Fix Record index violations --- src/client.ts | 4 +--- src/rubyLsp.ts | 4 ++-- src/status.ts | 2 +- src/test/suite/status.test.ts | 4 ++-- src/testController.ts | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/client.ts b/src/client.ts index 98fb8077..538c540e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -18,9 +18,7 @@ import { LOG_CHANNEL, LSP_NAME, ClientInterface } from "./common"; import { Telemetry, RequestEvent } from "./telemetry"; import { Ruby } from "./ruby"; -interface EnabledFeatures { - [key: string]: boolean; -} +type EnabledFeatures = Record; // Get the executables to start the server based on the user's configuration function getLspExecutables( diff --git a/src/rubyLsp.ts b/src/rubyLsp.ts index eea189b5..29ea0d54 100644 --- a/src/rubyLsp.ts +++ b/src/rubyLsp.ts @@ -187,7 +187,7 @@ export class RubyLsp { .contributes.configuration.properties["rubyLsp.enabledFeatures"] .properties; - const descriptions: { [key: string]: string } = {}; + const descriptions: Record = {}; Object.entries(enabledFeaturesProperties).forEach( ([key, value]: [string, any]) => { descriptions[key] = value.description; @@ -195,7 +195,7 @@ export class RubyLsp { ); const configuration = vscode.workspace.getConfiguration("rubyLsp"); - const features: { [key: string]: boolean } = + const features: Record = configuration.get("enabledFeatures")!; const allFeatures = Object.keys(features); const options: vscode.QuickPickItem[] = allFeatures.map((label) => { diff --git a/src/status.ts b/src/status.ts index df144c04..c2f37793 100644 --- a/src/status.ts +++ b/src/status.ts @@ -175,7 +175,7 @@ export class FeaturesStatus extends StatusItem { refresh(_workspace: WorkspaceInterface): void { const configuration = vscode.workspace.getConfiguration("rubyLsp"); - const features: { [key: string]: boolean } = + const features: Record = configuration.get("enabledFeatures")!; const enabledFeatures = Object.keys(features).filter( (key) => features[key], diff --git a/src/test/suite/status.test.ts b/src/test/suite/status.test.ts index de94c60f..679b29fc 100644 --- a/src/test/suite/status.test.ts +++ b/src/test/suite/status.test.ts @@ -209,7 +209,7 @@ suite("StatusItems", () => { suite("FeaturesStatus", () => { const configuration = vscode.workspace.getConfiguration("rubyLsp"); - const originalFeatures: { [key: string]: boolean } = + const originalFeatures: Record = configuration.get("enabledFeatures")!; const numberOfExperimentalFeatures = Object.values(originalFeatures).filter( (feature) => feature === false, @@ -256,7 +256,7 @@ suite("StatusItems", () => { .getConfiguration("rubyLsp") .update("enabledFeatures", { completion: false }, true, true); - const currentFeatures: { [key: string]: boolean } = vscode.workspace + const currentFeatures: Record = vscode.workspace .getConfiguration("rubyLsp") .get("enabledFeatures")!; diff --git a/src/testController.ts b/src/testController.ts index 34e770bb..400b9b81 100644 --- a/src/testController.ts +++ b/src/testController.ts @@ -75,7 +75,7 @@ export class TestController { this.testCommands.delete(test); }); - const groupIdMap: { [key: string]: vscode.TestItem } = {}; + const groupIdMap: Record = {}; let classTest: vscode.TestItem; const uri = vscode.Uri.from({