Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c7adbdd

Browse files
Merge pull request #4206 from PowerShell/andschwa/strict
Enable `strict` TypeScript mode etc.
2 parents b87cd98 + b8189fc commit c7adbdd

32 files changed

+842
-987
lines changed

‎src/controls/animatedStatusBar.ts‎

Lines changed: 0 additions & 145 deletions
This file was deleted.

‎src/controls/checkboxQuickPick.ts‎

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,17 @@ export interface ICheckboxQuickPickOptions {
1818
confirmPlaceHolder: string;
1919
}
2020

21-
const defaultOptions: ICheckboxQuickPickOptions = { confirmPlaceHolder: defaultPlaceHolder};
21+
const defaultOptions: ICheckboxQuickPickOptions = { confirmPlaceHolder: defaultPlaceHolder};
2222

23-
export function showCheckboxQuickPick(
23+
export asyncfunction showCheckboxQuickPick(
2424
items: ICheckboxQuickPickItem[],
25-
options: ICheckboxQuickPickOptions = defaultOptions): Thenable<ICheckboxQuickPickItem[]> {
26-
27-
return showInner(items, options).then(
28-
(selectedItem) => {
29-
// We're mutating the original item list so just return it for now.
30-
// If 'selectedItem' is undefined it means the user cancelled the
31-
// inner showQuickPick UI so pass the undefined along.
32-
return selectedItem !== undefined ? items : undefined;
33-
});
25+
options: ICheckboxQuickPickOptions = defaultOptions): Promise<ICheckboxQuickPickItem[] | undefined> {
26+
27+
const selectedItem = await showInner(items, options);
28+
return selectedItem !== undefined ? items : undefined;
3429
}
3530

3631
function getQuickPickItems(items: ICheckboxQuickPickItem[]): vscode.QuickPickItem[] {
37-
3832
const quickPickItems: vscode.QuickPickItem[] = [];
3933
quickPickItems.push({ label: confirmItemLabel, description: "" });
4034

@@ -48,40 +42,35 @@ function getQuickPickItems(items: ICheckboxQuickPickItem[]): vscode.QuickPickIte
4842
return quickPickItems;
4943
}
5044

51-
function showInner(
45+
asyncfunction showInner(
5246
items: ICheckboxQuickPickItem[],
53-
options: ICheckboxQuickPickOptions): Thenable<vscode.QuickPickItem> {
54-
55-
const quickPickThenable: Thenable<vscode.QuickPickItem> =
56-
vscode.window.showQuickPick(
57-
getQuickPickItems(items),
58-
{
59-
ignoreFocusOut: true,
60-
matchOnDescription: true,
61-
placeHolder: options.confirmPlaceHolder,
62-
});
63-
64-
return quickPickThenable.then(
65-
(selection) => {
66-
if (!selection) {
67-
return Promise.resolve<vscode.QuickPickItem>(undefined);
68-
}
69-
70-
if (selection.label === confirmItemLabel) {
71-
return selection;
72-
}
73-
74-
const index: number = getItemIndex(items, selection.label);
75-
76-
if (index >= 0) {
77-
toggleSelection(items[index]);
78-
} else {
79-
// tslint:disable-next-line:no-console
80-
console.log(`Couldn't find CheckboxQuickPickItem for label '${selection.label}'`);
81-
}
82-
83-
return showInner(items, options);
47+
options: ICheckboxQuickPickOptions): Promise<vscode.QuickPickItem | undefined> {
48+
49+
const selection = await vscode.window.showQuickPick(
50+
getQuickPickItems(items),
51+
{
52+
ignoreFocusOut: true,
53+
matchOnDescription: true,
54+
placeHolder: options.confirmPlaceHolder,
8455
});
56+
57+
if (selection === undefined) {
58+
return undefined;
59+
}
60+
61+
if (selection.label === confirmItemLabel) {
62+
return selection;
63+
}
64+
65+
const index: number = getItemIndex(items, selection.label);
66+
if (index >= 0) {
67+
toggleSelection(items[index]);
68+
} else {
69+
// tslint:disable-next-line:no-console
70+
console.log(`Couldn't find CheckboxQuickPickItem for label '${selection.label}'`);
71+
}
72+
73+
return showInner(items, options);
8574
}
8675

8776
function getItemIndex(items: ICheckboxQuickPickItem[], itemLabel: string): number {

‎src/features/CodeActions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class CodeActionsFeature implements vscode.Disposable {
1111

1212
constructor(private log: ILogger) {
1313
this.applyEditsCommand = vscode.commands.registerCommand("PowerShell.ApplyCodeActionEdits", (edit: any) => {
14-
Window.activeTextEditor.edit((editBuilder) => {
14+
Window.activeTextEditor?.edit((editBuilder) => {
1515
editBuilder.replace(
1616
new vscode.Range(
1717
edit.StartLineNumber - 1,

‎src/features/Console.ts‎

Lines changed: 17 additions & 16 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";
@@ -50,19 +48,17 @@ interface IShowChoicePromptRequestArgs {
5048
}
5149

5250
interface IShowChoicePromptResponseBody {
53-
responseText: string;
51+
responseText: string|undefined;
5452
promptCancelled: boolean;
5553
}
5654

5755
interface IShowInputPromptResponseBody {
58-
responseText: string;
56+
responseText: string|undefined;
5957
promptCancelled: boolean;
6058
}
6159

6260

63-
function showChoicePrompt(
64-
promptDetails: IShowChoicePromptRequestArgs,
65-
client: LanguageClient): Thenable<IShowChoicePromptResponseBody> {
61+
function showChoicePrompt(promptDetails: IShowChoicePromptRequestArgs): Thenable<IShowChoicePromptResponseBody> {
6662

6763
let resultThenable: Thenable<IShowChoicePromptResponseBody>;
6864

@@ -121,11 +117,12 @@ function showChoicePrompt(
121117
return resultThenable;
122118
}
123119

124-
function showInputPrompt(promptDetails: IShowInputPromptRequestArgs): Thenable<IShowInputPromptResponseBody> {
125-
return vscode.window.showInputBox({ placeHolder: promptDetails.name + ": " }).then(onInputEntered);
120+
async function showInputPrompt(promptDetails: IShowInputPromptRequestArgs): Promise<IShowInputPromptResponseBody> {
121+
const responseText = await vscode.window.showInputBox({ placeHolder: promptDetails.name + ": " });
122+
return onInputEntered(responseText);
126123
}
127124

128-
function onItemsSelected(chosenItems: ICheckboxQuickPickItem[]): IShowChoicePromptResponseBody {
125+
function onItemsSelected(chosenItems: ICheckboxQuickPickItem[]|undefined): IShowChoicePromptResponseBody {
129126
if (chosenItems !== undefined) {
130127
return {
131128
promptCancelled: false,
@@ -140,7 +137,7 @@ function onItemsSelected(chosenItems: ICheckboxQuickPickItem[]): IShowChoiceProm
140137
}
141138
}
142139

143-
function onItemSelected(chosenItem: vscode.QuickPickItem): IShowChoicePromptResponseBody {
140+
function onItemSelected(chosenItem: vscode.QuickPickItem|undefined): IShowChoicePromptResponseBody {
144141
if (chosenItem !== undefined) {
145142
return {
146143
promptCancelled: false,
@@ -155,7 +152,7 @@ function onItemSelected(chosenItem: vscode.QuickPickItem): IShowChoicePromptResp
155152
}
156153
}
157154

158-
function onInputEntered(responseText: string): IShowInputPromptResponseBody {
155+
function onInputEntered(responseText: string|undefined): IShowInputPromptResponseBody {
159156
if (responseText !== undefined) {
160157
return {
161158
promptCancelled: false,
@@ -171,7 +168,7 @@ function onInputEntered(responseText: string): IShowInputPromptResponseBody {
171168

172169
export class ConsoleFeature extends LanguageClientConsumer {
173170
private commands: vscode.Disposable[];
174-
private handlers: vscode.Disposable[];
171+
private handlers: vscode.Disposable[]=[];
175172

176173
constructor(private log: Logger) {
177174
super();
@@ -192,6 +189,10 @@ export class ConsoleFeature extends LanguageClientConsumer {
192189
}
193190

194191
const editor = vscode.window.activeTextEditor;
192+
if (editor === undefined) {
193+
return;
194+
}
195+
195196
let selectionRange: vscode.Range;
196197

197198
if (!editor.selection.isEmpty) {
@@ -200,7 +201,7 @@ export class ConsoleFeature extends LanguageClientConsumer {
200201
selectionRange = editor.document.lineAt(editor.selection.start.line).range;
201202
}
202203

203-
await this.languageClient.sendRequest(EvaluateRequestType, {
204+
await this.languageClient?.sendRequest(EvaluateRequestType, {
204205
expression: editor.document.getText(selectionRange),
205206
});
206207

@@ -221,12 +222,12 @@ export class ConsoleFeature extends LanguageClientConsumer {
221222
}
222223
}
223224

224-
public setLanguageClient(languageClient: LanguageClient) {
225+
public overridesetLanguageClient(languageClient: LanguageClient) {
225226
this.languageClient = languageClient;
226227
this.handlers = [
227228
this.languageClient.onRequest(
228229
ShowChoicePromptRequestType,
229-
(promptDetails) => showChoicePrompt(promptDetails,this.languageClient)),
230+
(promptDetails) => showChoicePrompt(promptDetails)),
230231

231232
this.languageClient.onRequest(
232233
ShowInputPromptRequestType,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /