Skip to content

Tweak strict types setup, fix type errors under strictTypes.ts - #806

Merged
ihrpr merged 1 commit into
ihrpr/zod-typesfrom
basil/zod-types-mods
Jul 24, 2025
Merged

ihrpr merged 1 commit into
ihrpr/zod-typesfrom
basil/zod-types-mods

Conversation

@bhosmer-ant

@bhosmer-ant bhosmer-ant commented Jul 24, 2025 •

Copy link
Copy Markdown
Contributor
  • Modified strict type generation to just remove .passthrough() (.strict() is ~a no-op)
  • Fixed a bunch of TypeScript errors that show up when using strictTypes.ts (SDK impl and tests)
  • Added a test pass that runs everything with strictTypes imported into src/client/index.ts, src/server/{index.ts,mcp.ts}
  • Added type annotations to Client/Server/McpServer methods for rollover ergo

@bhosmer-ant
bhosmer-ant requested a review from ihrpr July 24, 2025 04:35
- Modified strict type generation to just remove .passthrough() (.strict() is ~a no-op)
- Fixed TypeScript errors when using strictTypes.ts (impl and tests)
- Added a test pass that runs everything with strictTypes imported into src/client/index.ts, src/server/{index.ts,mcp.ts}
- Added type annotations to Client/Server/McpServer methods for rollover ergo
@bhosmer-ant
bhosmer-ant force-pushed the basil/zod-types-mods branch from 4f23e70 to a13c3bc Compare July 24, 2025 04:40
Comment thread package.json
"fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts",
"generate:strict-types": "tsx scripts/generateStrictTypes.ts",
"check:strict-types": "npm run generate:strict-types && git diff --exit-code src/strictTypes.ts || (echo 'Error: strictTypes.ts is out of date. Run npm run generate:strict-types' && exit 1)",
"test:strict-types": "node scripts/test-strict-types.js",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this temp replaces the imports of "types.js" with "strictTypes.js" and runs all tests


// Remove the @deprecated comment block
const deprecatedCommentPattern = /\/\*\*\s*\n\s*\*\s*@deprecated[\s\S]*?\*\/\s*\n/;
content = content.replace(deprecatedCommentPattern, '');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this omits the "passthrough will be deprecated" comment that's at the top of types.js

Comment thread src/server/index.ts

protected assertRequestHandlerCapability(method: string): void {
switch (method) {
case "sampling/createMessage":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that's the case that convinced me we need to fix types

@ihrpr
ihrpr merged commit 3607385 into ihrpr/zod-types Jul 24, 2025
@ihrpr
ihrpr deleted the basil/zod-types-mods branch July 24, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants