Skip to content

test: fix all test type errors and typecheck tests in CI - #143

Merged
mattpodwysocki merged 5 commits into
mainfrom
chore/test-type-errors
Oct 26, 2026
Merged

mattpodwysocki merged 5 commits into
mainfrom
chore/test-type-errors

Conversation

@mattpodwysocki

Copy link
Copy Markdown
Contributor

Same cleanup as mapbox/mcp-server#298. Stacked on #142 (SDK v2), so the base is feat/mcp-sdk-v2. I'll retarget it to main once #142 merges.

The tests were never typechecked (CI only builds src), and tsc -p tsconfig.test.json had 247 errors. All of them are on main too, so they're older than the v2 move.

What changed

  • New npm run typecheck (tsc over src and test), run in CI before the build.
  • tsconfig.test.json gets noEmit, so a plain tsc run can't write .js files next to the sources.
  • New test/utils/resultTestUtils.ts with textOf, resourceTextOf and promptTextOf. 238 errors were tests reading .text off a content block without checking it was text. The helpers narrow the type and throw a clear error on the wrong content type instead of comparing against undefined.
  • StyleBuilderTool.test.ts typed raw input with the parsed type, which makes render_type required even though the schema defaults it to 'auto'. It now uses z.input<typeof StyleBuilderToolSchema>.
  • CreateTokenTool.test.ts imported src/utils/types.js with a bare src/ path that doesn't resolve. Made it a relative type import.
  • resourceRegistry.test.ts casts the spied context to ServerContext.

Checked locally

  • npm run typecheck: 0 errors (was 247)
  • npm test: 650 passed
  • npm run lint: 0 errors, same 124 warnings as before
  • npm run format: clean

🤖 Generated with Claude Code

mattpodwysocki and others added 3 commits October 21, 2026 15:26
Swaps @modelcontextprotocol/sdk 1.x for the v2 packages
(@modelcontextprotocol/server and /core, plus /client for tests) and
ext-apps 2.0.3, same as mapbox/mcp-server#296. Ran the official
v1-to-v2 codemod, then:

- Replace the SDK output-validation patch with lenientOutputSchema, a
  Standard Schema wrapper that keeps the real schema in tools/list but only
  warns on a mismatch. Tools that return text only get structuredContent {}.
- Register prompt argument schemas as z.object(), since v2 deprecates raw
  shapes.
- Move test request contexts to the v2 shape (http.authInfo) so the token
  checks actually run.
- Add tests that make a real tools/call through McpServer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds npm run typecheck (tsc over src and test) as a CI step. Fixes the
247 errors it found: content/resource/prompt text reads go through
helpers that narrow the block type, StyleBuilderTool tests use the
schema's input type, and a bare src/ import is made relative. Sets
noEmit in tsconfig.test.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattpodwysocki
mattpodwysocki requested a review from a team as a code owner October 23, 2026 14:20
@mattpodwysocki mattpodwysocki added the enhancement New feature or request label Oct 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ctufts
ctufts previously approved these changes Oct 23, 2026
@mattpodwysocki
mattpodwysocki changed the base branch from feat/mcp-sdk-v2 to main October 26, 2026 14:23
@mattpodwysocki
mattpodwysocki dismissed ctufts’s stale review October 26, 2026 14:23

The base branch was changed.

# Conflicts:
#	test/resources/resourceRegistry.test.ts
@mattpodwysocki
mattpodwysocki merged commit 2ac064f into main Oct 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants