Repository navigation
Description
Problem
The root project (src/: the CLI and the server) is never type-checked. CI type-checks only desktop/ (bun run lint in .github/workflows/ci.yml), and Bun runs TypeScript without checking types, so tests pass regardless.
Running tsc --noEmit at the root reports several thousand errors. New code in src/ therefore has no type gate: in #299 the only way to check a change was to diff the error list before and after by hand.
Where the errors come from
Measured in a clean worktree on 2893b320 with the root tsconfig.json (TypeScript 6.0.3, --ignoreDeprecations 6.0): 6,439 errors. An earlier count in this issue (about 6,700, on 89678866 in a checkout with more directories) used a different scope.
| Cause | Errors | Notes |
|---|---|---|
| React Compiler output committed as source | about 2,500 remain after everything below is fixed | 390 .tsx files under src/ import react/compiler-runtime. Parameter types were dropped when they were compiled, for example export function useAppState(selector) { in src/state/AppState.tsx. This is the terminal UI. It is the main source of TS7006 (implicit any parameter) |
| No React types in the root project | 1,656 × TS7016 | package.json depends on react but had no @types/react. An earlier version of this issue attributed most TS7006 errors to this; measured, adding the types removes only 286 of them |
| Type files that are generated stubs | about 900 at the import sites | 167 files under src/ carry @generated stub from scan-missing-imports (written by desktop/scripts/scan-missing-imports.ts). 31 of them are used only as type sources, src/types/message.ts being the largest (imported by 201 files). 100 stand in for runtime modules that do not exist in this repository. Four more hand-written empty files under src/entrypoints/sdk/ have the same effect |
| Missing declarations | about 560 | react/compiler-runtime exports no c in @types/react; the global MACRO set in preload.ts; .md text modules; ink's custom JSX elements |
The root tsconfig.json has no include |
210 | It also checked desktop/, vendor/, website/ and experiments/, which have their own configs. In a checkout with refs/ or worktrees under .claude/worktrees, the check ran out of memory |
Other missing @types/* packages |
37 | ws, semver, qrcode, react-reconciler, shell-quote, picomatch, turndown, proper-lockfile, stack-utils |
| Other | about 1,000 | Type mismatches in .ts files and hand-written .tsx files. Not reviewed one by one |
A further finding: 541 .tsx files, including all 390 compiled ones, end with an inline source map that contains the original source with its type annotations.
Plan
- Limit the root
tsconfig.jsonto the code it owns (src/,scripts/,stubs/, the two preload files), drop the deprecatedbaseUrl, and add atypecheckscript. - Add
@types/reactand the other missing@types/*packages. - Add the missing declarations and replace the type-only stub files with real types. Every type is taken from evidence in the repository: Zod schemas, constructor functions, literal usage, or types from dependencies.
- Compiled React Compiler output: the terminal UI is not under active development, so these files are marked
// @ts-nocheckand left as they are. Exports that checked code calls get their signatures back from the inline source maps. - Go through what is left in
.tsand hand-written.tsxfiles. - Once the count is zero, add the root type check to CI.
Each step reports the error count before and after.
Progress
Steps 1 to 3 are done on a local branch and not yet in a PR: 6,439 → 6,219 (scope) → 5,210 (@types/react) → 3,499 (declarations and 29 type files, no change to runtime code). Six type names had no evidence in the repository and are still missing.
Not covered by any type check
desktop/sidecars/dreamcoder-sidecar.ts, desktop/scripts/*.ts and experiments/. desktop/tsconfig.json includes only desktop/src, and desktop/electron/tsconfig.json only desktop/electron.
Found along the way
- Plugin reload without an active session leaves custom agents out of the count #301: plugin reload without an active session leaves custom agents out of the count.
src/buddy/observer.ts:32-38readsroleandcontentat the top level of internal messages, which havetypeandmessage.contentinstead, so the terminal UI companion never speaks. From reading the code, not from running it.src/cli/print.tshandles 11 control request subtypes (for exampleside_question,generate_session_title,remote_control) that are missing from the request union insrc/entrypoints/sdk/controlSchemas.ts. Runtime is unaffected because these schemas are not used for validation.src/keybindings/defaultBindings.ts:196,271use the contextsScrollandMessageActions, which are not in the list insrc/keybindings/schema.ts:12-32.
Activity