-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
- 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
4f23e70
to
a13c3bc
Compare
@@ -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", |
There was a problem hiding this comment.
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, ''); |
There was a problem hiding this comment.
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": |
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.