Skip to content

Commit 08808a4

Browse files
committed
test: add type assertion to bypass type check
1 parent fc9ca5f commit 08808a4

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/examples/server/mcpServerOutputSchema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ server.registerTool(
4343
void country;
4444
// Simulate weather API call
4545
const temp_c = Math.round((Math.random() * 35 - 5) * 10) / 10;
46-
const conditions = ["sunny", "cloudy", "rainy", "stormy", "snowy"][Math.floor(Math.random() * 5)];
46+
const conditions = ["sunny", "cloudy", "rainy", "stormy", "snowy"][Math.floor(Math.random() * 5)] as unknown as "sunny" | "cloudy" | "rainy" | "stormy" | "snowy";
4747

4848
const structuredContent = {
4949
temperature: {
@@ -77,4 +77,4 @@ async function main() {
7777
main().catch((error) => {
7878
console.error("Server error:", error);
7979
process.exit(1);
80-
});
80+
});

src/server/mcp.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ describe("tool()", () => {
12481248
processedInput: input,
12491249
resultType: "structured",
12501250
// Missing required 'timestamp' field
1251+
someExtraField: "unexpected" // Extra field not in schema
12511252
} as unknown as { processedInput: string; resultType: string; timestamp: string }, // Type assertion to bypass TypeScript validation for testing purposes
12521253
})
12531254
);

0 commit comments

Comments
 (0)