Remove unnecessary type assertions across codebase

Add oxlint-tsgolint and configure typescript/no-unnecessary-type-assertion
to flag redundant `!` and `as Foo` casts. Type-aware mode is left off by
default to keep `npm run lint` fast; the rule sits configured for when we
turn type-aware on intentionally. Auto-fix removed ~283 redundant casts;
two manual touch-ups: a real tsgolint false positive in split-container.tsx
and a stale ChildProcess import after a double-cast collapsed.
This commit is contained in:
Mohamed Boudra
2026-05-05 19:56:26 +07:00
parent 78fe3e4df3
commit 4cd9e76bd2
129 changed files with 409 additions and 323 deletions
@@ -752,7 +752,7 @@ describe("ProjectSettingsScreen — save flow", () => {
await flush();
expect(client.writeProjectConfig).toHaveBeenCalledTimes(1);
const callArg = client.writeProjectConfig.mock.calls[0]![0] as {
const callArg = client.writeProjectConfig.mock.calls[0][0] as {
repoRoot: string;
config: PaseoConfigRaw;
expectedRevision: PaseoConfigRevision | null;
@@ -767,7 +767,7 @@ describe("ProjectSettingsScreen — save flow", () => {
// Subsequent saves use the freshly-returned revision.
click(requireById("save-button"));
await flush();
const secondArg = client.writeProjectConfig.mock.calls[1]![0] as {
const secondArg = client.writeProjectConfig.mock.calls[1][0] as {
expectedRevision: PaseoConfigRevision;
};
expect(secondArg.expectedRevision).toEqual(newRevision);
@@ -869,7 +869,7 @@ describe("ProjectSettingsScreen — round-trip semantics", () => {
click(requireById("save-button"));
await flush();
const savedConfig = client.writeProjectConfig.mock.calls[0]![0]!.config as PaseoConfigRaw;
const savedConfig = client.writeProjectConfig.mock.calls[0][0]!.config as PaseoConfigRaw;
// string stays string when edited in place
expect(savedConfig.worktree?.setup).toBe("npm install\nnpm run prepare");
});
@@ -897,7 +897,7 @@ describe("ProjectSettingsScreen — round-trip semantics", () => {
click(requireById("save-button"));
await flush();
const savedConfig = client.writeProjectConfig.mock.calls[0]![0]!.config as PaseoConfigRaw;
const savedConfig = client.writeProjectConfig.mock.calls[0][0]!.config as PaseoConfigRaw;
expect(savedConfig.worktree?.teardown).toEqual(["docker compose down", "rm -rf .cache"]);
});
@@ -920,7 +920,7 @@ describe("ProjectSettingsScreen — round-trip semantics", () => {
click(requireById("save-button"));
await flush();
const savedConfig = client.writeProjectConfig.mock.calls[0]![0]!.config as PaseoConfigRaw;
const savedConfig = client.writeProjectConfig.mock.calls[0][0]!.config as PaseoConfigRaw;
expect(savedConfig.worktree?.setup).toBe("npm install");
});
@@ -943,7 +943,7 @@ describe("ProjectSettingsScreen — round-trip semantics", () => {
click(requireById("save-button"));
await flush();
const savedConfig = client.writeProjectConfig.mock.calls[0]![0]!.config as PaseoConfigRaw;
const savedConfig = client.writeProjectConfig.mock.calls[0][0]!.config as PaseoConfigRaw;
expect(savedConfig.worktree?.setup).toEqual(["npm install", "npm run prepare"]);
});
});
@@ -996,7 +996,7 @@ describe("ProjectSettingsScreen — scripts editor", () => {
click(requireById("save-button"));
await flush();
const savedConfig = client.writeProjectConfig.mock.calls[0]![0]!.config as PaseoConfigRaw;
const savedConfig = client.writeProjectConfig.mock.calls[0][0]!.config as PaseoConfigRaw;
const scriptKeys = Object.keys((savedConfig as Record<string, unknown>).scripts ?? {});
// One of the two scripts was removed.
expect(scriptKeys.length).toBe(1);
@@ -1031,7 +1031,7 @@ describe("ProjectSettingsScreen — scripts editor", () => {
click(requireById("save-button"));
await flush();
const savedConfig = client.writeProjectConfig.mock.calls[0]![0]!.config as PaseoConfigRaw;
const savedConfig = client.writeProjectConfig.mock.calls[0][0]!.config as PaseoConfigRaw;
expect((savedConfig as Record<string, unknown>).customTopLevel).toBe("preserved");
const worktreeRecord = (savedConfig.worktree ?? {}) as Record<string, unknown>;
expect(worktreeRecord.customWorktreeField).toBe("keep");
@@ -1541,7 +1541,7 @@ function WorkspaceScreenContent({
if (!client || !workspaceDirectory) {
throw new Error("Host is not connected");
}
return (await client.getCheckoutStatus(workspaceDirectory)) as CheckoutStatusPayload;
return await client.getCheckoutStatus(workspaceDirectory);
},
staleTime: Infinity,
refetchOnMount: false,
@@ -68,7 +68,7 @@ describe("computeWorkspaceTabLayout", () => {
expect(result.closeButtonPolicy).toBe("all");
expect(result.requiresHorizontalScrollFallback).toBe(false);
expect(result.items.map((item) => item.width)).toEqual([60, 60, 60, 60]);
expect(result.items.every((item) => item.showLabel === false)).toBe(true);
expect(result.items.every((item) => !item.showLabel)).toBe(true);
});
it("allows horizontal scroll only when icon-only tabs still cannot fit", () => {
@@ -81,7 +81,7 @@ describe("computeWorkspaceTabLayout", () => {
expect(result.closeButtonPolicy).toBe("all");
expect(result.requiresHorizontalScrollFallback).toBe(true);
expect(result.items.map((item) => item.width)).toEqual([60, 60, 60, 60]);
expect(result.items.every((item) => item.showLabel === false)).toBe(true);
expect(result.items.every((item) => !item.showLabel)).toBe(true);
});
it("returns empty layout details when there are no tabs", () => {
@@ -23,7 +23,7 @@ describe("deriveWorkspaceTabModel", () => {
];
const model = deriveWorkspaceTabModel({
tabs: [uiTabs[0]!, uiTabs[2]!, uiTabs[1]!],
tabs: [uiTabs[0], uiTabs[2], uiTabs[1]],
});
expect(model.tabs.map((tab) => tab.descriptor.tabId)).toEqual([