Skip to content

Commit bddc3e3

Browse files
committed
Enable 'strict' TypeScript compiler option
1 parent 5775d52 commit bddc3e3

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

src/features/DebugSession.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -428,20 +428,18 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
428428
pid: "current",
429429
}];
430430

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

439438
items.push({
440-
label: hostProcesses[p].processName,
441-
description: `PID: ${hostProcesses[p].processId.toString()}${windowTitle}`,
442-
pid: hostProcesses[p].processId,
439+
label: process.processName,
440+
description: `PID: ${process.processId.toString()}${windowTitle}`,
441+
pid: process.processId,
443442
});
444-
}
445443
}
446444

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

src/features/GetCommands.ts

+1-1
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

+1-1
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

+1-1
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

+4-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class Logger implements ILogger {
135135
}
136136

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

140140
this.logSessionPath =
141141
vscode.Uri.joinPath(
@@ -146,8 +146,9 @@ export class Logger implements ILogger {
146146
await vscode.workspace.fs.createDirectory(this.logSessionPath);
147147
}
148148

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

src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
122122

123123
// Setup the logger.
124124
logger = new Logger(context.globalStorageUri);
125-
logger.MinimumLogLevel = LogLevel[settings.developer.editorServicesLogLevel];
125+
logger.MinimumLogLevel = Logger.logLevelNameToValue(settings.developer.editorServicesLogLevel);
126126

127127
sessionManager = new SessionManager(
128128
context,

tsconfig.json

+1-7
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)