Skip to content

Commit 2ebcaa5

Browse files
committed
fix(ci): Reorder CI steps and fix implicit any types
PROBLEM: - TypeCheck failing: Cannot find module '@parseflow/core' - 3 implicit 'any' type errors in tools/index.ts ROOT CAUSE: 1. CI runs typecheck BEFORE build - mcp-server depends on @parseflow/core - But pdf-parser-core not compiled yet - No type definitions available 2. Missing type annotations - map() callback parameters have implicit 'any' - formatToc() item parameter has implicit 'any' SOLUTION: 1. Reorder CI steps: Before: install lint typecheck build test After: install build lint typecheck test Why: In monorepo, dependent packages need to be built first 2. Add explicit type annotations: - Import TOCItem type from @parseflow/core - Add types to map callback: (r: {page, context}, i: number) - Add type to formatToc: (items: TOCItem[], level) 3. Auto-fix Prettier formatting VERIFICATION: pnpm build: SUCCESS pnpm typecheck: 0 errors (was 6) pnpm lint: 0 errors pnpm test: 5/5 passing CI should now pass on all platforms.
1 parent 236d87d commit 2ebcaa5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ jobs:
4545
- name: Install dependencies
4646
run: pnpm install
4747

48+
- name: Build
49+
run: pnpm build
50+
4851
- name: Lint
4952
run: pnpm lint
5053

5154
- name: Type check
5255
run: pnpm typecheck
5356

54-
- name: Build
55-
run: pnpm build
56-
5757
- name: Test
5858
run: pnpm test
5959

packages/mcp-server/src/tools/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { Tool, TextContent } from '@modelcontextprotocol/sdk/types.js';
6-
import { PDFParser } from '@parseflow/core';
6+
import { PDFParser, type TOCItem } from '@parseflow/core';
77
import { logger } from '../utils/logger.js';
88
import { PathResolver } from '../utils/path-resolver.js';
99
import { handleError } from '../utils/error-handler.js';
@@ -223,7 +223,10 @@ export class ToolHandler {
223223
results.length === 0
224224
? '未找到匹配结果'
225225
: `找到 ${results.length} 个结果:\n\n${results
226-
.map((r, i) => `[${i + 1}] 第 ${r.page} 页\n${r.context}\n`)
226+
.map(
227+
(r: { page: number; context: string }, i: number) =>
228+
`[${i + 1}] 第 ${r.page} 页\n${r.context}\n`
229+
)
227230
.join('\n')}`;
228231

229232
return {
@@ -338,9 +341,9 @@ ${JSON.stringify(structuredData, null, 2)}`;
338341
};
339342
}
340343

341-
const formatToc = (items: typeof toc, level = 0): string => {
344+
const formatToc = (items: TOCItem[], level = 0): string => {
342345
return items
343-
.map((item) => {
346+
.map((item: TOCItem) => {
344347
const indent = ' '.repeat(level);
345348
let result = `${indent}${item.title} (第 ${item.page} 页)`;
346349
if (item.children && item.children.length > 0) {

0 commit comments

Comments
 (0)