Skip to content

Commit 146825b

Browse files
committed
Enable 'strict' TypeScript compiler option
1 parent e774ae8 commit 146825b

13 files changed

+16
-41
lines changed

src/features/Console.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
"use strict";
5-
64
import vscode = require("vscode");
75
import { NotificationType, RequestType } from "vscode-languageclient";
86
import { LanguageClient } from "vscode-languageclient/node";

src/features/DebugSession.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
"use strict";
5-
64
import vscode = require("vscode");
75
import { CancellationToken, DebugConfiguration, DebugConfigurationProvider,
86
ExtensionContext, WorkspaceFolder } from "vscode";
@@ -428,20 +426,18 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
428426
pid: "current",
429427
}];
430428

431-
const hostProcesses = await this.languageClient?.sendRequest(GetPSHostProcessesRequestType, {});
432-
for (const p in hostProcesses) {
433-
if (hostProcesses.hasOwnProperty(p)) {
429+
const response = await this.languageClient?.sendRequest(GetPSHostProcessesRequestType, {});
430+
for (const process of response?.hostProcesses ?? []) {
434431
let windowTitle = "";
435-
if (hostProcesses[p].mainWindowTitle) {
436-
windowTitle = `, Title: ${hostProcesses[p].mainWindowTitle}`;
432+
if (process.mainWindowTitle) {
433+
windowTitle = `, Title: ${process.mainWindowTitle}`;
437434
}
438435

439436
items.push({
440-
label: hostProcesses[p].processName,
441-
description: `PID: ${hostProcesses[p].processId.toString()}${windowTitle}`,
442-
pid: hostProcesses[p].processId,
437+
label: process.processName,
438+
description: `PID: ${process.processId.toString()}${windowTitle}`,
439+
pid: process.processId,
443440
});
444-
}
445441
}
446442

447443
if (items.length === 0) {

src/features/ExtensionCommands.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
// TODO: This file needs some TLC to use strict mode.
5-
64
import * as os from "os";
75
import * as path from "path";
86
import * as vscode from "vscode";

src/features/GetCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class Command extends vscode.TreeItem {
139139
};
140140
}
141141

142-
public async getChildren(_element?): Promise<Command[]> {
142+
public async getChildren(_element?: any): Promise<Command[]> {
143143
return [];
144144
// Returning an empty array because we need to return something.
145145
}

src/features/HelpCompletion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class HelpCompletionFeature extends LanguageClientConsumer {
2525

2626
if (this.settings.helpCompletion !== Settings.CommentType.Disabled) {
2727
this.helpCompletionProvider = new HelpCompletionProvider();
28-
const subscriptions = [];
28+
const subscriptions: Disposable[] = [];
2929
workspace.onDidChangeTextDocument(this.onEvent, this, subscriptions);
3030
this.disposable = Disposable.from(...subscriptions);
3131
}

src/features/RemoteFiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class RemoteFilesFeature extends LanguageClientConsumer {
6060
const remoteDocuments =
6161
vscode.workspace.textDocuments.filter((doc) => this.isDocumentRemote(doc));
6262

63-
async function innerCloseFiles() {
63+
async function innerCloseFiles(): Promise<void> {
6464
const doc = remoteDocuments.pop();
6565
if (doc === undefined) {
6666
return;

src/logging.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
"use strict";
5-
64
import utils = require("./utils");
75
import os = require("os");
86
import vscode = require("vscode");
@@ -135,7 +133,7 @@ export class Logger implements ILogger {
135133
}
136134

137135
public async startNewLog(minimumLogLevel: string = "Normal"): Promise<void> {
138-
this.MinimumLogLevel = this.logLevelNameToValue(minimumLogLevel.trim());
136+
this.MinimumLogLevel = Logger.logLevelNameToValue(minimumLogLevel);
139137

140138
this.logSessionPath =
141139
vscode.Uri.joinPath(
@@ -146,8 +144,9 @@ export class Logger implements ILogger {
146144
await vscode.workspace.fs.createDirectory(this.logSessionPath);
147145
}
148146

149-
private logLevelNameToValue(logLevelName: string): LogLevel {
150-
switch (logLevelName.toLowerCase()) {
147+
// TODO: Make the enum smarter about strings so this goes away.
148+
public static logLevelNameToValue(logLevelName: string): LogLevel {
149+
switch (logLevelName.trim().toLowerCase()) {
151150
case "diagnostic": return LogLevel.Diagnostic;
152151
case "verbose": return LogLevel.Verbose;
153152
case "normal": return LogLevel.Normal;

src/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
"use strict";
5-
64
import vscode = require("vscode");
75
import TelemetryReporter from "@vscode/extension-telemetry";
86
import { DocumentSelector } from "vscode-languageclient";
@@ -122,7 +120,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
122120

123121
// Setup the logger.
124122
logger = new Logger(context.globalStorageUri);
125-
logger.MinimumLogLevel = LogLevel[settings.developer.editorServicesLogLevel];
123+
logger.MinimumLogLevel = Logger.logLevelNameToValue(settings.developer.editorServicesLogLevel);
126124

127125
sessionManager = new SessionManager(
128126
context,

src/session.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
"use strict";
5-
64
import net = require("net");
75
import path = require("path");
86
import * as semver from "semver";

src/settings.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
"use strict";
5-
64
import vscode = require("vscode");
75
import utils = require("./utils");
86
import os = require("os");

src/utils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
"use strict";
5-
64
import os = require("os");
75
import path = require("path");
86
import vscode = require("vscode");

test/utils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
"use strict";
5-
64
import * as path from "path";
75
import * as vscode from "vscode";
86
import { IPowerShellExtensionClient } from "../src/features/ExternalApi";

tsconfig.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
],
1212
"sourceMap": true,
1313
"rootDir": ".",
14-
// TODO: We need to enable stricter checking...
15-
// "strict": true,
16-
"strictBindCallApply": true,
17-
"strictFunctionTypes": true,
18-
"strictNullChecks": true,
19-
"strictPropertyInitialization": true,
20-
"useUnknownInCatchVariables": true,
14+
"strict": true,
2115
"noImplicitReturns": true,
2216
"noFallthroughCasesInSwitch": true,
2317
"noUnusedParameters": true

0 commit comments

Comments
 (0)