fix(vscode): resolve unsafe type assertion lint errors (#19006)

This commit is contained in:
Emily Hedlund
2026-02-13 09:54:41 -08:00
committed by GitHub
parent 3bed7bbe8d
commit b16c9a5ebd
2 changed files with 12 additions and 16 deletions

View File

@@ -243,12 +243,10 @@ export class DiffManager {
// Find and close the tab corresponding to the diff view
for (const tabGroup of vscode.window.tabGroups.all) {
for (const tab of tabGroup.tabs) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const input = tab.input as {
modified?: vscode.Uri;
original?: vscode.Uri;
};
if (input && input.modified?.toString() === rightDocUri.toString()) {
if (
tab.input instanceof vscode.TabInputTextDiff &&
tab.input.modified.toString() === rightDocUri.toString()
) {
await vscode.window.tabGroups.close(tab);
return;
}

View File

@@ -112,6 +112,11 @@ function sendIdeContextUpdateNotification(
transport.send(notification);
}
function getSessionId(req: Request): string | undefined {
const header = req.headers[MCP_SESSION_ID_HEADER];
return Array.isArray(header) ? header[0] : header;
}
export class IDEServer {
private server: HTTPServer | undefined;
private context: vscode.ExtensionContext | undefined;
@@ -206,10 +211,7 @@ export class IDEServer {
context.subscriptions.push(onDidChangeDiffSubscription);
app.post('/mcp', async (req: Request, res: Response) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const sessionId = req.headers[MCP_SESSION_ID_HEADER] as
| string
| undefined;
const sessionId = getSessionId(req);
let transport: StreamableHTTPServerTransport;
if (sessionId && this.transports[sessionId]) {
@@ -291,10 +293,7 @@ export class IDEServer {
});
const handleSessionRequest = async (req: Request, res: Response) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const sessionId = req.headers[MCP_SESSION_ID_HEADER] as
| string
| undefined;
const sessionId = getSessionId(req);
if (!sessionId || !this.transports[sessionId]) {
this.log('Invalid or missing session ID');
res.status(400).send('Invalid or missing session ID');
@@ -339,8 +338,7 @@ export class IDEServer {
});
this.server = app.listen(0, '127.0.0.1', async () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const address = (this.server as HTTPServer).address();
const address = this.server?.address();
if (address && typeof address !== 'string') {
this.port = address.port;
this.log(`IDE server listening on http://127.0.0.1:${this.port}`);