Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

bhosmer-ant
Copy link
Contributor

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

  • 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
@@ -38,6 +38,7 @@
"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
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

@@ -11,6 +11,10 @@ const strictTypesPath = join(__dirname, '../src/strictTypes.ts');

let content = readFileSync(typesPath, 'utf-8');

// Remove the @deprecated comment block
const deprecatedCommentPattern = /\/\*\*\s*\n\s*\*\s*@deprecated[\s\S]*?\*\/\s*\n/;
content = content.replace(deprecatedCommentPattern, '');
Copy link
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

@@ -206,14 +209,6 @@ export class Server<

protected assertRequestHandlerCapability(method: string): void {
switch (method) {
case "sampling/createMessage":
Copy link
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
2 checks passed
@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