Skip to content

test(cli,tui): typecheck the __tests__ dirs (split from #1767 — 76 type errors to resolve) #1791

Description

@cliffhall

Summary

Split out from #1767 (the third of its three bullets) during the tidy-bundle PR that closed the rest. The cli and tui typecheck scripts (tsc --noEmit -p tsconfig.json, added in #1689) include only src and exclude **/*.test.{ts,tsx}, so the __tests__ dirs — which do the most as casting — get no tsc pass. web already typechecks its tests via tsc -b.

A spike (adding a tsconfig.test.json per client that includes __tests__ with the test-exclusions removed, and running tsc --noEmit on it) surfaces 76 errors — cli 58, tui 18 — which is why this was carved out of the tidy bundle rather than rushed:

cli:  24× TS7006 (implicit any params)
      19× TS2345 (partial mocks passed where InspectorClient / InspectorServerSettings expected)
      15× TS2307 (test-only module aliases tsc doesn't resolve:
                  @modelcontextprotocol/inspector-test-server, @inspector/core/mcp/index.js)
tui:   6× TS2322, 5× TS2556, 4× TS2345, 1× TS2741, 1× TS2739, 1× TS2353

Proposed

  • Add a tsconfig.test.json to clients/cli and clients/tui that inherits the base compilerOptions, includes __tests__/**/*, and drops the **/*.test.* exclusions. Add the test-only path aliases (@modelcontextprotocol/inspector-test-server, the @inspector/core/* deep paths) so tsc resolves what vitest resolves via resolve/projectResolve.
  • Fold tsc --noEmit -p tsconfig.test.json into each client's typecheck (it already runs the src-only config).
  • Fix what it surfaces. The implicit-anys are trivial annotations; the alias errors are the config above; the partial-mock TS2345s should be fixed with typed mock factories where practical rather than a spray of as unknown as casts (per the AGENTS.md as-cast policy) — a shared makeFakeInspectorClient() / makeFakeServerSettings() helper is likely the right shape.

Notes

Metadata

Metadata

Assignees

Labels

v2Issues and PRs for v2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions