Skip to content

Commit 4fa8d5d

Browse files
committed
Fix some always true/false errors in codebase
Testing out latest TS nightly that can identify when an expression is always true/false. This caught a few likely coding mistakes in our codebase Unsure about the intent in some of these cases but I've tried my best to understand them. Pinging relevant code owners for the confusing cases
1 parent d4d2ee3 commit 4fa8d5d

File tree

13 files changed

+17
-17
lines changed

13 files changed

+17
-17
lines changed

extensions/github-authentication/src/githubServer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export class GitHubServer implements IGitHubServer {
197197
throw new Error(`${result.status} ${result.statusText}`);
198198
}
199199
} catch (e) {
200-
this._logger.warn('Failed to delete token from server.' + e.message ?? e);
200+
this._logger.warn('Failed to delete token from server.' + (e.message ?? e));
201201
}
202202
}
203203

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
"ts-loader": "^9.4.2",
210210
"ts-node": "^10.9.1",
211211
"tsec": "0.2.7",
212-
"typescript": "^5.6.0-dev.20240715",
212+
"typescript": "^5.6.0-dev.20240723",
213213
"util": "^0.12.4",
214214
"vscode-nls-dev": "^3.3.1",
215215
"webpack": "^5.91.0",

src/vs/editor/standalone/test/browser/monarch.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ suite('Monarch', () => {
233233
uselessReplaceKey2: '@uselessReplaceKey3',
234234
uselessReplaceKey3: '@uselessReplaceKey4',
235235
uselessReplaceKey4: '@uselessReplaceKey5',
236-
uselessReplaceKey5: '@ham' || '',
236+
uselessReplaceKey5: '@ham',
237237
tokenizer: {
238238
root: [
239239
{

src/vs/platform/files/test/browser/indexedDBFileService.integrationTest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ flakySuite('IndexedDBFileSystemProvider', function () {
189189
assert.strictEqual(value.mtime, undefined);
190190
assert.strictEqual(value.ctime, undefined);
191191
} else {
192-
assert.ok(!'Unexpected value ' + basename(value.resource));
192+
assert.fail('Unexpected value ' + basename(value.resource));
193193
}
194194
});
195195
});

src/vs/platform/files/test/node/diskFileService.integrationTest.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ flakySuite('Disk File Service', function () {
273273
assert.strictEqual(value.mtime, undefined);
274274
assert.strictEqual(value.ctime, undefined);
275275
} else {
276-
assert.ok(!'Unexpected value ' + basename(value.resource.fsPath));
276+
assert.fail('Unexpected value ' + basename(value.resource.fsPath));
277277
}
278278
});
279279
});
@@ -317,7 +317,7 @@ flakySuite('Disk File Service', function () {
317317
assert.ok(value.mtime > 0);
318318
assert.ok(value.ctime > 0);
319319
} else {
320-
assert.ok(!'Unexpected value ' + basename(value.resource.fsPath));
320+
assert.fail('Unexpected value ' + basename(value.resource.fsPath));
321321
}
322322
});
323323
});

src/vs/workbench/contrib/comments/browser/simpleCommentEditor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class SimpleCommentEditor extends CodeEditorWidget {
145145
export function calculateEditorHeight(parentEditor: LayoutableEditor, editor: ICodeEditor, currentHeight: number): number {
146146
const layoutInfo = editor.getLayoutInfo();
147147
const lineHeight = editor.getOption(EditorOption.lineHeight);
148-
const contentHeight = (editor._getViewModel()?.getLineCount()! * lineHeight) ?? editor.getContentHeight(); // Can't just call getContentHeight() because it returns an incorrect, large, value when the editor is first created.
148+
const contentHeight = (editor._getViewModel()?.getLineCount()! * lineHeight); // Can't just call getContentHeight() because it returns an incorrect, large, value when the editor is first created.
149149
if ((contentHeight > layoutInfo.height) ||
150150
(contentHeight < layoutInfo.height && currentHeight > MIN_EDITOR_HEIGHT)) {
151151
const linesToAdd = Math.ceil((contentHeight - layoutInfo.height) / lineHeight);

src/vs/workbench/contrib/customEditor/browser/customEditors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
132132
priority: contributedEditor.priority,
133133
},
134134
{
135-
singlePerResource: () => !this.getCustomEditorCapabilities(contributedEditor.id)?.supportsMultipleEditorsPerDocument ?? true
135+
singlePerResource: () => !(this.getCustomEditorCapabilities(contributedEditor.id)?.supportsMultipleEditorsPerDocument ?? false)
136136
},
137137
{
138138
createEditorInput: ({ resource }, group) => {

src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
615615
// We need to first wait for extensions to be registered because we might read
616616
// the `TaskDefinitionRegistry` in case `type` is `undefined`
617617
await this._extensionService.whenInstalledExtensionsRegistered();
618-
this._log('Activating task providers ' + type ?? 'all');
618+
this._log('Activating task providers ' + (type ?? 'all'));
619619
await raceTimeout(
620620
Promise.all(this._getActivationEvents(type).map(activationEvent => this._extensionService.activateByEvent(activationEvent))),
621621
5000,

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
16331633
id: TerminalStatus.ShellIntegrationAttentionNeeded,
16341634
severity: Severity.Warning,
16351635
icon: Codicon.warning,
1636-
tooltip: (`${exitMessage} ` ?? '') + nls.localize('launchFailed.exitCodeOnlyShellIntegration', 'Disabling shell integration in user settings might help.'),
1636+
tooltip: `${exitMessage} ` + nls.localize('launchFailed.exitCodeOnlyShellIntegration', 'Disabling shell integration in user settings might help.'),
16371637
hoverActions: [{
16381638
commandId: TerminalCommandId.ShellIntegrationLearnMore,
16391639
label: nls.localize('shellIntegration.learnMore', "Learn more about shell integration"),

src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export class TerminalChatController extends Disposable implements ITerminalContr
274274
}
275275

276276
hasFocus(): boolean {
277-
return !!this._chatWidget?.rawValue?.hasFocus() ?? false;
277+
return this._chatWidget?.rawValue?.hasFocus() ?? false;
278278
}
279279

280280
populateHistory(up: boolean) {

src/vs/workbench/contrib/testing/browser/testingExplorerView.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class TestingExplorerView extends ViewPane {
136136
}
137137

138138
public override shouldShowWelcome() {
139-
return this.viewModel?.welcomeExperience === WelcomeExperience.ForWorkspace ?? true;
139+
return this.viewModel ? this.viewModel.welcomeExperience === WelcomeExperience.ForWorkspace : true;
140140
}
141141

142142
public override focus() {

src/vs/workbench/contrib/timeline/browser/timelinePane.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function isLoadMoreCommand(item: TreeElement | undefined): item is LoadMoreComma
6767
}
6868

6969
function isTimelineItem(item: TreeElement | undefined): item is TimelineItem {
70-
return !item?.handle.startsWith('vscode-command:') ?? false;
70+
return !!item && !item.handle.startsWith('vscode-command:');
7171
}
7272

7373
function updateRelativeTime(item: TimelineItem, lastRelativeTime: string | undefined): string | undefined {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -10321,10 +10321,10 @@ typescript@^4.7.4:
1032110321
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
1032210322
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==
1032310323

10324-
typescript@^5.6.0-dev.20240715:
10325-
version "5.6.0-dev.20240715"
10326-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.0-dev.20240715.tgz#18b9e994f99916b90917943d5de8e78f781d1d70"
10327-
integrity sha512-CLF8WFoqLgHgxQqjklkEOw3gT99Y2YNU4+TfkJurX5bfejAUYpb2jBjiYOn5Rq9HCew6ceZlRaG7Q++6/fBvVA==
10324+
typescript@^5.6.0-dev.20240723:
10325+
version "5.6.0-dev.20240723"
10326+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.0-dev.20240723.tgz#de2cbd7a67f356af4122359a44efb6a6805dd823"
10327+
integrity sha512-IciIh6EUuMxUQ9OvnmBtrkJwuVD9zWhl9smsA+5yYz9Zpodi5qs4qhp4KldiUj86dRGREtT3+10PpUX7RMm02Q==
1032810328

1032910329
typical@^4.0.0:
1033010330
version "4.0.0"

0 commit comments

Comments
 (0)