Skip to content

An open-source, faster Devin alternative

TypeScript

chore(web): enable type-aware linting (recommendedTypeChecked) + fix fallout

Igor Zalutski3342c063b47e
diff --git a/web/eslint.config.js b/web/eslint.config.js
index 4fb9a967..849f6264 100644
--- a/web/eslint.config.js
+++ b/web/eslint.config.js
@@ -11,7 +11,22 @@ export default tseslint.config(
ignores: ['dist'],
},
js.configs.recommended,
- ...tseslint.configs.recommended,
+ ...tseslint.configs.recommendedTypeChecked,
+ {
+ languageOptions: {
+ parserOptions: {
+ projectService: {
+ allowDefaultProject: ['*.config.ts', 'eslint.config.js'],
+ },
+ tsconfigRootDir: import.meta.dirname,
+ },
+ },
+ },
+ {
+ // Config files aren't part of the app tsconfig → no type-aware linting.
+ files: ['**/*.config.{ts,js}', 'eslint.config.js'],
+ extends: [tseslint.configs.disableTypeChecked],
+ },
jsxA11y.flatConfigs.recommended,
reactRefresh.configs.vite,
{
diff --git a/web/src/api/client.ts b/web/src/api/client.ts
index 3edc9421..1cf78e42 100644
--- a/web/src/api/client.ts
+++ b/web/src/api/client.ts
@@ -51,6 +51,21 @@ function validate<T>(
return data as T
}
+// Extract a human message from an error body of unknown shape. OC dashboard
+// returns {error: "string"}; sessions-api returns {error: {type, message}}.
+function errorMessage(body: unknown, status: number): string {
+ if (body && typeof body === 'object') {
+ const b = body as Record<string, unknown>
+ if (typeof b.error === 'string') return b.error
+ if (b.error && typeof b.error === 'object') {
+ const inner = (b.error as Record<string, unknown>).message
+ if (typeof inner === 'string') return inner
+ }
+ if (typeof b.message === 'string') return b.message
+ }
+ return `Request failed: ${status}`
+}
+
export async function apiFetch<T>(
path: string,
options: RequestInit = {},
@@ -81,17 +96,8 @@ export async function apiFetch<T>(
}
if (!res.ok) {
- const body = await res.json().catch(() => ({}))
- // OC dashboard returns {error: "string"}; sessions-api returns
- // {error: {type, message}}. Handle both so we don't surface
- // "[object Object]" when the proxy talks to sessions-api.
- let msg: string
- if (typeof body.error === 'string') msg = body.error
- else if (body.error && typeof body.error.message === 'string')
- msg = body.error.message
- else if (typeof body.message === 'string') msg = body.message
- else msg = `Request failed: ${res.status}`
- throw new Error(msg)
+ const body: unknown = await res.json().catch(() => ({}))
+ throw new Error(errorMessage(body, res.status))
}
if (res.status === 204) {
@@ -112,9 +118,10 @@ export async function logout(): Promise<void> {
method: 'POST',
credentials: 'include',
})
- const body = await res.json().catch(() => ({}))
- if (body && typeof body.logoutUrl === 'string' && body.logoutUrl) {
- dest = body.logoutUrl
+ const body: unknown = await res.json().catch(() => ({}))
+ if (body && typeof body === 'object') {
+ const url = (body as Record<string, unknown>).logoutUrl
+ if (typeof url === 'string' && url) dest = url
}
} catch {
// ignore — fall back to /auth/login
@@ -488,7 +495,9 @@ export const getAgentLogs = (agentId: string, tail = 300) =>
// ── Per-agent paywalled feature subscriptions (Telegram et al) ──
-export type EntitlementReason = 'ungated' | 'subscription_required' | string
+// Known values: 'ungated' | 'subscription_required'; typed as string so a new
+// server reason never fails typing.
+export type EntitlementReason = string
export interface AgentEntitlement {
feature: string
diff --git a/web/src/api/mock.ts b/web/src/api/mock.ts
index 113c86ca..95785f00 100644
--- a/web/src/api/mock.ts
+++ b/web/src/api/mock.ts
@@ -395,10 +395,7 @@ const ROUTES: Array<[RegExp, Handler]> = [
[/^\/agents$/, () => []],
]
-export async function mockFetch<T>(
- path: string,
- options: RequestInit = {},
-): Promise<T> {
+export function mockFetch<T>(path: string, options: RequestInit = {}): T {
const method = (options.method ?? 'GET').toUpperCase()
if (method !== 'GET') return {} as T
for (const [re, handler] of ROUTES) {
diff --git a/web/src/components/LogsPanel.tsx b/web/src/components/LogsPanel.tsx
index c4242e17..4a1098b0 100644
--- a/web/src/components/LogsPanel.tsx
+++ b/web/src/components/LogsPanel.tsx
@@ -104,7 +104,7 @@ export default function LogsPanel({ sandboxId, onClose }: LogsPanelProps) {
es.onmessage = (e) => {
let ev: LogEvent
try {
- ev = JSON.parse(e.data) as LogEvent
+ ev = JSON.parse(e.data as string) as LogEvent
} catch {
return
}
@@ -130,7 +130,6 @@ export default function LogsPanel({ sandboxId, onClose }: LogsPanelProps) {
es.close()
setConnState('closed')
}
- // eslint-disable-next-line react-hooks/exhaustive-deps
}, [sandboxId])
// When unpausing, drain the paused buffer into events.
diff --git a/web/src/components/Terminal.tsx b/web/src/components/Terminal.tsx
index ab4c8942..63b989a4 100644
--- a/web/src/components/Terminal.tsx
+++ b/web/src/components/Terminal.tsx
@@ -91,12 +91,23 @@ export default function Terminal({ sandboxId, onClose }: TerminalProps) {
})
if (!res.ok) {
- const data = await res.json()
- throw new Error(data.error || `HTTP ${res.status}`)
+ const data: unknown = await res.json().catch(() => null)
+ const err =
+ data && typeof data === 'object'
+ ? (data as Record<string, unknown>).error
+ : undefined
+ throw new Error(typeof err === 'string' ? err : `HTTP ${res.status}`)
}
- const { sessionId } = await res.json()
+ const payload: unknown = await res.json()
if (disposed) return
+ const sessionId =
+ payload && typeof payload === 'object'
+ ? (payload as Record<string, unknown>).sessionId
+ : undefined
+ if (typeof sessionId !== 'string') {
+ throw new Error('Invalid PTY session response')
+ }
ptySessionIdRef.current = sessionId
// Connect WebSocket
@@ -160,7 +171,7 @@ export default function Terminal({ sandboxId, onClose }: TerminalProps) {
}
}
- initTerminal()
+ void initTerminal()
// Handle window resize
const handleResize = () => {
diff --git a/web/src/components/app-shell.tsx b/web/src/components/app-shell.tsx
index 64a252e5..4383a797 100644
--- a/web/src/components/app-shell.tsx
+++ b/web/src/components/app-shell.tsx
@@ -85,7 +85,9 @@ function OrgSwitcher() {
{orgs.map((org) => (
<DropdownMenuItem
key={org.id}
- onClick={() => !org.isActive && switchOrg(org.id)}
+ onClick={() => {
+ if (!org.isActive) void switchOrg(org.id)
+ }}
className="gap-2"
>
<Check
@@ -152,7 +154,7 @@ function SidebarNav({ onNavigate }: { onNavigate?: () => void }) {
{user?.email}
</span>
<button
- onClick={() => logout()}
+ onClick={() => void logout()}
aria-label="Sign out"
title="Sign out"
className="text-muted-foreground/40 hover:text-foreground flex size-7 shrink-0 items-center justify-center transition-colors"
diff --git a/web/src/pages/APIKeys.tsx b/web/src/pages/APIKeys.tsx
index 409f1479..d3e7713b 100644
--- a/web/src/pages/APIKeys.tsx
+++ b/web/src/pages/APIKeys.tsx
@@ -43,7 +43,7 @@ export default function APIKeys() {
setCreatedKey(data.key)
setShowCreate(false)
setNewKeyName('')
- queryClient.invalidateQueries({ queryKey: ['api-keys'] })
+ void queryClient.invalidateQueries({ queryKey: ['api-keys'] })
},
onError: (error) => notifyError("Couldn't create the API key.", error),
})
diff --git a/web/src/pages/Billing.tsx b/web/src/pages/Billing.tsx
index fd9b4ae1..46bac7ca 100644
--- a/web/src/pages/Billing.tsx
+++ b/web/src/pages/Billing.tsx
@@ -93,7 +93,7 @@ function PlanTab() {
const redeemMutation = useMutation({
mutationFn: () => redeemPromoCode(promoCode),
onSuccess: (data) => {
- queryClient.invalidateQueries({ queryKey: ['billing'] })
+ void queryClient.invalidateQueries({ queryKey: ['billing'] })
setPromoCode('')
toast.success(
`$${(data.creditAppliedCents / 100).toFixed(2)} credit applied`,
@@ -261,7 +261,7 @@ function PrepaidPlan() {
// existing card was charged server-side, so just refresh the balance.
const onPurchase = (data: { url: string | null }) => {
if (data.url) window.location.href = data.url
- else queryClient.invalidateQueries({ queryKey: ['autumn-billing'] })
+ else void queryClient.invalidateQueries({ queryKey: ['autumn-billing'] })
}
const topupMutation = useMutation({
mutationFn: () => autumnTopup(amount),
@@ -463,7 +463,7 @@ function AutoTopupCard({
window.location.href = data.url
return
}
- queryClient.invalidateQueries({ queryKey: ['autumn-billing'] })
+ void queryClient.invalidateQueries({ queryKey: ['autumn-billing'] })
setDraft({}) // server config is canonical again
markSaved()
},
diff --git a/web/src/pages/Checkpoints.tsx b/web/src/pages/Checkpoints.tsx
index 7c3929ac..040c2873 100644
--- a/web/src/pages/Checkpoints.tsx
+++ b/web/src/pages/Checkpoints.tsx
@@ -47,7 +47,7 @@ export default function Checkpoints() {
mutationFn: (id: string) => deleteCheckpointDashboard(id),
onError: (error) => notifyError("Couldn't delete the checkpoint.", error),
onSettled: () =>
- queryClient.invalidateQueries({ queryKey: ['checkpoints'] }),
+ void queryClient.invalidateQueries({ queryKey: ['checkpoints'] }),
})
const confirmDelete = () => {
diff --git a/web/src/pages/SessionDetail.tsx b/web/src/pages/SessionDetail.tsx
index bffeb81d..53b60424 100644
--- a/web/src/pages/SessionDetail.tsx
+++ b/web/src/pages/SessionDetail.tsx
@@ -78,9 +78,13 @@ export default function SessionDetail() {
})
const invalidate = () => {
- queryClient.invalidateQueries({ queryKey: ['session-detail', sandboxId] })
- queryClient.invalidateQueries({ queryKey: ['session-stats', sandboxId] })
- queryClient.invalidateQueries({ queryKey: ['sessions'] })
+ void queryClient.invalidateQueries({
+ queryKey: ['session-detail', sandboxId],
+ })
+ void queryClient.invalidateQueries({
+ queryKey: ['session-stats', sandboxId],
+ })
+ void queryClient.invalidateQueries({ queryKey: ['sessions'] })
}
const deleteMutation = useMutation({
@@ -141,7 +145,10 @@ export default function SessionDetail() {
title="Sandbox not found"
description="This sandbox may have been deleted."
action={
- <Button variant="outline" onClick={() => navigate('/sandboxes')}>
+ <Button
+ variant="outline"
+ onClick={() => void navigate('/sandboxes')}
+ >
Back to Sandboxes
</Button>
}
diff --git a/web/src/pages/Sessions.tsx b/web/src/pages/Sessions.tsx
index d47ff4de..203c40d0 100644
--- a/web/src/pages/Sessions.tsx
+++ b/web/src/pages/Sessions.tsx
@@ -57,7 +57,7 @@ export default function Sessions() {
},
onError: (error) => notifyError("Couldn't delete the sandbox.", error),
onSettled: () => {
- queryClient.invalidateQueries({ queryKey: ['sessions'] })
+ void queryClient.invalidateQueries({ queryKey: ['sessions'] })
},
})
diff --git a/web/src/pages/Settings.tsx b/web/src/pages/Settings.tsx
index da297949..5dc436a9 100644
--- a/web/src/pages/Settings.tsx
+++ b/web/src/pages/Settings.tsx
@@ -79,7 +79,7 @@ export default function Settings() {
const saveMutation = useMutation({
mutationFn: (n: string) => updateOrg(n),
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: ['org'] })
+ void queryClient.invalidateQueries({ queryKey: ['org'] })
setDraftName(null)
markSaved()
},
@@ -89,7 +89,7 @@ export default function Settings() {
const setDomainMutation = useMutation({
mutationFn: (domain: string) => setCustomDomain(domain),
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: ['org'] })
+ void queryClient.invalidateQueries({ queryKey: ['org'] })
setDomainInput('')
},
onError: (e) => notifyError("Couldn't set the custom domain.", e),
@@ -185,50 +185,50 @@ export default function Settings() {
{hasDomain ? (
<div className="space-y-4">
- <ReadOnlyField label="Domain" value={`*.${org!.customDomain}`} />
+ <ReadOnlyField label="Domain" value={`*.${org.customDomain}`} />
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
<div className="space-y-1.5">
<Label>Verification</Label>
<div>
- <DomainStatus status={org!.domainVerificationStatus} />
+ <DomainStatus status={org.domainVerificationStatus} />
</div>
</div>
<div className="space-y-1.5">
<Label>SSL</Label>
<div>
- <DomainStatus status={org!.domainSslStatus} />
+ <DomainStatus status={org.domainSslStatus} />
</div>
</div>
</div>
- {org!.verificationTxtName || org!.sslTxtName ? (
+ {org.verificationTxtName || org.sslTxtName ? (
<div className="space-y-1.5">
<Label>Required DNS TXT records</Label>
<CodeBlock>
- {org!.verificationTxtName ? (
- <div className={org!.sslTxtName ? 'mb-3' : ''}>
+ {org.verificationTxtName ? (
+ <div className={org.sslTxtName ? 'mb-3' : ''}>
<div className="text-foreground font-semibold">
Domain verification
</div>
- <div>Name: {org!.verificationTxtName}</div>
- <div>Value: {org!.verificationTxtValue}</div>
+ <div>Name: {org.verificationTxtName}</div>
+ <div>Value: {org.verificationTxtValue}</div>
</div>
) : null}
- {org!.sslTxtName ? (
+ {org.sslTxtName ? (
<div>
<div className="text-foreground font-semibold">
SSL validation
</div>
- <div>Name: {org!.sslTxtName}</div>
- <div>Value: {org!.sslTxtValue}</div>
+ <div>Name: {org.sslTxtName}</div>
+ <div>Value: {org.sslTxtValue}</div>
</div>
) : null}
</CodeBlock>
</div>
) : null}
- {org!.domainVerificationStatus === 'active' ? (
+ {org.domainVerificationStatus === 'active' ? (
<div className="space-y-1.5">
<Label>Preview URL setup</Label>
<CodeBlock>
@@ -241,7 +241,7 @@ export default function Settings() {
<div>
Name:{' '}
<span className="text-foreground">
- *.{org!.customDomain}
+ *.{org.customDomain}
</span>
</div>
<div>
@@ -337,8 +337,8 @@ function TeamMembers() {
const inviteMutation = useMutation({
mutationFn: (email: string) => sendInvitation(email),
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: ['org-members'] })
- queryClient.invalidateQueries({ queryKey: ['org-invitations'] })
+ void queryClient.invalidateQueries({ queryKey: ['org-members'] })
+ void queryClient.invalidateQueries({ queryKey: ['org-invitations'] })
setInviteEmail('')
setShowInvite(false)
},
@@ -349,7 +349,7 @@ function TeamMembers() {
mutationFn: (membershipId: string) => removeMember(membershipId),
onError: (e) => notifyError("Couldn't remove the member.", e),
onSettled: () =>
- queryClient.invalidateQueries({ queryKey: ['org-members'] }),
+ void queryClient.invalidateQueries({ queryKey: ['org-members'] }),
})
return (
@@ -460,7 +460,7 @@ function PendingInvitations() {
mutationFn: (id: string) => revokeInvitation(id),
onError: (e) => notifyError("Couldn't revoke the invitation.", e),
onSettled: () =>
- queryClient.invalidateQueries({ queryKey: ['org-invitations'] }),
+ void queryClient.invalidateQueries({ queryKey: ['org-invitations'] }),
})
const pending = (invitations ?? []).filter((inv) => inv.state === 'pending')
diff --git a/web/src/pages/Templates.tsx b/web/src/pages/Templates.tsx
index 8401e068..79341872 100644
--- a/web/src/pages/Templates.tsx
+++ b/web/src/pages/Templates.tsx
@@ -38,9 +38,9 @@ function formatSteps(manifest: Record<string, unknown>): string {
return `env: ${n} var(s)`
}
case 'workdir':
- return `workdir: ${args.path ?? '...'}`
+ return `workdir: ${typeof args.path === 'string' ? args.path : '...'}`
case 'add_file':
- return `file: ${args.path ?? '...'}`
+ return `file: ${typeof args.path === 'string' ? args.path : '...'}`
default:
return t || 'step'
}