Issue #473 reported that `bun run typecheck` fails on main with ~4400
errors due to repo-foundation drift, masking branch-specific
regressions. Per kevincodex1's guidance ("lets narrow the typecheck
scope for now and then we expand step by step") this PR addresses the
foundational root causes and brings the error count down 60% so the
gate is actionable for branch reviews.
Changes:
- tsconfig.json: bump target to ES2023 + add lib ["ES2023", "DOM"]
so Array.findLast / findLastIndex resolve (kills 41 TS2550 errors).
Add `noEmit: true` for typecheck-only mode and
`allowImportingTsExtensions: true` (kills 40 TS5097 errors). Set
`noImplicitAny: false` because cleaning up TSX-component implicit
any is explicitly out of scope per the issue.
- src/global.d.ts: ambient declaration for the build-time MACRO
global injected by scripts/build.ts via Bun's `define` option
(kills 9 TS2304 'Cannot find name MACRO' errors).
- src/types/{message,utils,tools}.ts: stubs for the highest-impact
missing modules from the partial source snapshot (~21 importers
for message alone). Document the snapshot caveat at the top of each
stub and reference issue #473 so future readers know they're
placeholders.
- src/entrypoints/sdk/controlTypes.ts and src/constants/querySource.ts:
similar one-file stubs unblocking 18 + 19 importers respectively.
- src/entrypoints/agentSdkTypes.ts: append `any`-typed aliases for
~70 SDK names that callers expect on the public surface but that
live in stubbed sub-files (PermissionMode, SDKCompactBoundaryMessage,
HookEvent, ModelUsage, ModelInfo, etc. — exactly the list from
auriti's bug-report enumeration).
Verified locally on Linux:
- baseline `bunx tsc --noEmit` on stashed main: 4434 errors
- with PR applied: 1782 errors (60% drop)
- `bun run build`: passes (v0.7.0)
- `bun test`: 1632 pass; the 4
remaining failures (StartupScreen, thinking) reproduce on main
and are unrelated.
- TS2550 (lib): 41 → 0
- TS5097 (.ts imports): 40 → 0
- TS2304 'MACRO': 9 → 0
- TS2307 missing modules: 587 → 325
Remaining errors are localized to specific stubbed modules and can
be addressed in smaller follow-up issues, matching the issue's
"Definition of done" criterion.
- package.json with all 70+ dependencies
- Bun build script with feature flag shims, native module stubs, otel externals
- Stubs for ~15 missing source files (snapshot gaps)
- tsconfig.json for TypeScript
- bin/openclaude entry point
- Builds to single 19MB dist/cli.mjs
- Verified: --version and --help work
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>