Skip to content

Commit 11f04e1

Browse files
authored
Check script which typechecks using Typescripts new Go port (#1075)
1 parent 9757ace commit 11f04e1

File tree

8 files changed

+133
-10
lines changed

8 files changed

+133
-10
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
cache: npm
2323

2424
- run: npm ci
25+
- run: npm run check
2526
- run: npm run build
2627
- run: npm test
27-
- run: npm run lint
2828

2929
publish:
3030
runs-on: ubuntu-latest

package-lock.json

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
"dist"
6060
],
6161
"scripts": {
62-
"fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts",
62+
"fetch:spec-types": "curl -o ./src/spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts",
63+
"typecheck": "tsgo --noEmit",
6364
"build": "npm run build:esm && npm run build:cjs",
6465
"build:esm": "mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json && tsc -p tsconfig.prod.json",
6566
"build:esm:w": "npm run build:esm -- -w",
@@ -69,6 +70,7 @@
6970
"prepack": "npm run build:esm && npm run build:cjs",
7071
"lint": "eslint src/ && prettier --check .",
7172
"lint:fix": "eslint src/ --fix && prettier --write .",
73+
"check": "npm run fetch:spec-types && npm run typecheck && npm run lint",
7274
"test": "npm run fetch:spec-types && jest",
7375
"start": "npm run server",
7476
"server": "tsx watch --clear-screen=false scripts/cli.ts server",
@@ -111,6 +113,7 @@
111113
"@types/node": "^22.0.2",
112114
"@types/supertest": "^6.0.2",
113115
"@types/ws": "^8.5.12",
116+
"@typescript/native-preview": "^7.0.0-dev.20251103.1",
114117
"eslint": "^9.8.0",
115118
"eslint-config-prettier": "^10.1.8",
116119
"jest": "^29.7.0",

src/client/streamableHttp.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ export class StreamableHTTPClientTransport implements Transport {
311311
// if something happens reader will throw
312312
try {
313313
// Create a pipeline: binary stream -> text decoder -> SSE parser
314-
const reader = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).getReader();
314+
const reader = stream
315+
.pipeThrough(new TextDecoderStream() as ReadableWritablePair<string, Uint8Array>)
316+
.pipeThrough(new EventSourceParserStream())
317+
.getReader();
315318

316319
while (true) {
317320
const { value: event, done } = await reader.read();

src/examples/server/simpleStreamableHttp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import {
1515
} from '../../types.js';
1616
import { InMemoryEventStore } from '../shared/inMemoryEventStore.js';
1717
import { setupAuthServer } from './demoInMemoryOAuthProvider.js';
18-
import { OAuthMetadata } from 'src/shared/auth.js';
19-
import { checkResourceAllowed } from 'src/shared/auth-utils.js';
18+
import { OAuthMetadata } from '../../shared/auth.js';
19+
import { checkResourceAllowed } from '../../shared/auth-utils.js';
2020

2121
import cors from 'cors';
2222

src/server/sse.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { McpServer } from './mcp.js';
55
import { createServer, type Server } from 'node:http';
66
import { AddressInfo } from 'node:net';
77
import { z } from 'zod';
8-
import { CallToolResult, JSONRPCMessage } from 'src/types.js';
8+
import { CallToolResult, JSONRPCMessage } from '../types.js';
99

1010
const createMockResponse = () => {
1111
const res = {

src/spec.types.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* (note: a few don't have SDK types, see MISSING_SDK_TYPES below)
77
*/
88
import * as SDKTypes from './types.js';
9-
import * as SpecTypes from '../spec.types.js';
9+
import * as SpecTypes from './spec.types.js';
1010
import fs from 'node:fs';
1111

1212
/* eslint-disable @typescript-eslint/no-unused-vars */
@@ -443,7 +443,7 @@ const sdkTypeChecks = {
443443
};
444444

445445
// This file is .gitignore'd, and fetched by `npm run fetch:spec-types` (called by `npm run test`)
446-
const SPEC_TYPES_FILE = 'spec.types.ts';
446+
const SPEC_TYPES_FILE = 'src/spec.types.ts';
447447
const SDK_TYPES_FILE = 'src/types.ts';
448448

449449
const MISSING_SDK_TYPES = [

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
"resolveJsonModule": true,
1414
"isolatedModules": true,
1515
"skipLibCheck": true,
16-
"baseUrl": ".",
1716
"paths": {
18-
"pkce-challenge": ["node_modules/pkce-challenge/dist/index.node"]
17+
"pkce-challenge": ["./node_modules/pkce-challenge/dist/index.node"]
1918
}
2019
},
2120
"include": ["src/**/*"],

0 commit comments

Comments
 (0)