8000 [mcp] Also emit bailout messages with no loc by poteto · Pull Request #32937 · facebook/react · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[mcp] Also emit bailout messages with no loc #32937

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
Apr 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions compiler/packages/react-mcp-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ server.tool(
}
}
};
const errors: Array<{message: string; loc: SourceLocation}> = [];
const errors: Array<{message: string; loc: SourceLocation | null}> = [];
const compilerOptions: Partial<PluginOptions> = {
panicThreshold: 'none',
logger: {
Expand All @@ -170,12 +170,10 @@ server.tool(
detail.loc == null || typeof detail.loc == 'symbol'
? event.fnLoc
: detail.loc;
if (loc != null) {
errors.push({
message: detail.reason,
loc,
});
}
errors.push({
message: detail.reason,
loc,
});
}
},
},
Expand Down Expand Up @@ -279,17 +277,16 @@ server.tool(
}
}
if (errors.length > 0) {
const errMessages = errors.map(err => {
if (typeof err.loc !== 'symbol') {
return {
content: errors.map(err => {
return {
type: 'text' as const,
text: `React Compiler bailed out:\n\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`,
text:
err.loc === null || typeof err.loc === 'symbol'
? `React Compiler bailed out:\n\n${err.message}`
: `React Compiler bailed out:\n\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`,
};
}
return null;
});
return {
content: errMessages.filter(msg => msg !== null),
}),
};
}
return {
Expand Down
Loading
0