Skip to content

Commit df51ca2

Browse files
Revert in correct type changes
1 parent 396dcfa commit df51ca2

12 files changed

Lines changed: 19 additions & 44 deletions

File tree

packages/common/src/util/uniqWithHash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function uniqWithHash<T>(
5151
// For hash collisions, uniq the items,
5252
// letting uniqWith provide correct semantics.
5353
needsUniq.forEach((key) => {
54-
hashToItems.set(key, uniqWith(hashToItems.get(key) ?? [], isEqual));
54+
hashToItems.set(key, uniqWith(hashToItems.get(key), isEqual));
5555
});
5656

5757
// To preserve order, step through the original items

packages/cursorless-engine/src/generateSpokenForm/generateSpokenForm.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ suite("Generate spoken forms", () => {
5050
regex: "foo",
5151
});
5252

53-
if (spokenForm.type !== "success") {
54-
assert.fail("Expected spoken form generation to succeed");
55-
}
53+
assert(spokenForm.type === "success");
5654
assert.equal(spokenForm.spokenForms, "bar");
5755
});
5856
});
@@ -77,9 +75,7 @@ async function runTest(file: string) {
7775
const hatMapSpokenForm = generator.processCommand(
7876
getHatMapCommand(fixture.marksToCheck),
7977
);
80-
if (hatMapSpokenForm.type !== "success") {
81-
assert.fail("Expected hat map spoken form generation to succeed");
82-
}
78+
assert(hatMapSpokenForm.type === "success");
8379
assert(hatMapSpokenForm.spokenForms.length === 1);
8480
generatedSpokenForm.spokenForms[0] += " " + hatMapSpokenForm.spokenForms[0];
8581
}

packages/cursorless-engine/src/test/spokenForms.talon.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ async function runRecordedFixture(repl: TalonRepl, file: string) {
6363
commands.push(getHatMapCommand(fixture.marksToCheck));
6464
}
6565

66-
if (fixture.command.spokenForm == null) {
67-
assert.fail("Expected spoken form to be defined");
68-
}
66+
assert(fixture.command.spokenForm != null);
6967

7068
await runTest(repl, fixture.command.spokenForm, commands);
7169
}

packages/cursorless-tutorial/src/stepComponentParsers/CursorlessCommandComponentParser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ function substituteMissingHats(
115115

116116
// Update the hats in the initial state snapshot
117117
if (initialState.marks != null) {
118-
const { marks } = initialState;
119118
initialState = produce(initialState, (draft) => {
120-
draft.marks = mapKeys(marks, (_value, key) => {
119+
draft.marks = mapKeys(draft.marks, (_value, key) => {
121120
const { hatStyle, character } = splitKey(key);
122121
if (enabledHatStyles[hatStyle] === undefined) {
123122
return getKey(Object.keys(enabledHatStyles)[0], character);

packages/cursorless-vscode-e2e/src/suite/breakpoints.vscode.test.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ async function breakpointAdd() {
3434

3535
const breakpoints = vscode.debug.breakpoints;
3636
assert.deepStrictEqual(breakpoints.length, 1);
37+
assert.ok(breakpoints[0] instanceof vscode.SourceBreakpoint);
3738
const breakpoint = breakpoints[0];
38-
if (!(breakpoint instanceof vscode.SourceBreakpoint)) {
39-
assert.fail("Expected breakpoint to be a SourceBreakpoint");
40-
}
4139
assert.ok(breakpoint.location.range.isEqual(new vscode.Range(0, 0, 0, 0)));
4240
}
4341

@@ -49,10 +47,8 @@ async function breakpointTokenAdd() {
4947

5048
const breakpoints = vscode.debug.breakpoints;
5149
assert.deepStrictEqual(breakpoints.length, 1);
50+
assert.ok(breakpoints[0] instanceof vscode.SourceBreakpoint);
5251
const breakpoint = breakpoints[0];
53-
if (!(breakpoint instanceof vscode.SourceBreakpoint)) {
54-
assert.fail("Expected breakpoint to be a SourceBreakpoint");
55-
}
5652
assert.ok(breakpoint.location.range.isEqual(new vscode.Range(0, 2, 0, 7)));
5753
}
5854

@@ -94,10 +90,8 @@ async function breakpointTokenRemove() {
9490

9591
const breakpoints = vscode.debug.breakpoints;
9692
assert.deepStrictEqual(breakpoints.length, 1);
93+
assert.ok(breakpoints[0] instanceof vscode.SourceBreakpoint);
9794
const breakpoint = breakpoints[0];
98-
if (!(breakpoint instanceof vscode.SourceBreakpoint)) {
99-
assert.fail("Expected breakpoint to be a SourceBreakpoint");
100-
}
10195
assert.ok(breakpoint.location.range.isEqual(new vscode.Range(0, 0, 0, 0)));
10296
}
10397

packages/cursorless-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ async function runTest() {
4747

4848
const editor = window.activeTextEditor;
4949

50-
if (editor == null) {
51-
assert.fail("No editor was focused");
52-
}
53-
50+
assert.ok(editor != null, "No editor was focused");
5451
assert.deepStrictEqual(editor.document.getText(editor.selection), "world");
5552
}

packages/cursorless-vscode-e2e/src/suite/intraCellSetSelection.vscode.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ async function runTest() {
3131
);
3232
});
3333

34-
if (targetHat == null) {
35-
assert.fail('Expected a default hat for "world" in the cell');
36-
}
34+
assert(targetHat != null, 'Expected a default hat for "world" in the cell');
3735
const { hatStyle, character } = splitKey(targetHat[0]);
3836

3937
await runCursorlessCommand({
@@ -54,9 +52,7 @@ async function runTest() {
5452

5553
const editor = window.activeTextEditor;
5654

57-
if (editor == null) {
58-
assert.fail("No editor was focused");
59-
}
55+
assert.ok(editor != null, "No editor was focused");
6056

6157
assert.deepStrictEqual(editor.document.getText(editor.selection), "world");
6258
}

packages/node-common/src/FileSystemTutorialContentProvider.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type {
33
TutorialContentProvider,
44
TutorialId,
55
} from "@cursorless/common";
6-
import type { Dirent } from "node:fs";
76
import { readFile, readdir } from "node:fs/promises";
87
import path from "path";
98
import { loadFixture } from "./loadFixture";
@@ -22,10 +21,8 @@ export class FileSystemTutorialContentProvider implements TutorialContentProvide
2221

2322
return await Promise.all(
2423
tutorialDirs
25-
.filter((dirent: Dirent) => dirent.isDirectory())
26-
.map((dirent: Dirent) =>
27-
this.loadTutorialScript(dirent.name as TutorialId),
28-
),
24+
.filter((dirent) => dirent.isDirectory())
25+
.map((dirent) => this.loadTutorialScript(dirent.name as TutorialId)),
2926
);
3027
}
3128

packages/node-common/src/walkAsync.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { Dirent } from "node:fs";
21
import * as path from "path";
32
import { readdir } from "fs/promises";
43
import { flatten } from "lodash-es";
@@ -18,7 +17,7 @@ export const walkFiles = async (
1817

1918
const files = flatten(
2019
await Promise.all(
21-
dirEntries.map(async (dirent: Dirent) => {
20+
dirEntries.map(async (dirent) => {
2221
const filePath = path.join(dir, dirent.name);
2322
return dirent.isDirectory() ? await walkFiles(filePath) : [filePath];
2423
}),

packages/node-common/src/walkSync.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { Dirent } from "node:fs";
21
import * as path from "path";
32
import { readdirSync } from "fs";
43

@@ -11,7 +10,7 @@ import { readdirSync } from "fs";
1110
*/
1211
export const walkFilesSync = (dir: string): string[] => {
1312
let filelist: string[] = [];
14-
readdirSync(dir, { withFileTypes: true }).forEach((dirent: Dirent) => {
13+
readdirSync(dir, { withFileTypes: true }).forEach((dirent) => {
1514
const filePath = path.join(dir, dirent.name);
1615
if (dirent.isDirectory()) {
1716
filelist = filelist.concat(walkFilesSync(filePath));
@@ -32,7 +31,7 @@ export const walkDirsSync = (dir: string): string[] => {
3231
// Inner function returns absolute paths
3332
const walkDirsSyncInner = (dir: string): string[] => {
3433
let dirlist: string[] = [];
35-
readdirSync(dir, { withFileTypes: true }).forEach((dirent: Dirent) => {
34+
readdirSync(dir, { withFileTypes: true }).forEach((dirent) => {
3635
if (dirent.isDirectory()) {
3736
const dirPath = path.join(dir, dirent.name);
3837
dirlist.push(dirPath);

0 commit comments

Comments
 (0)