Remove as any in vscode-api-tests

Part of #269213
This commit is contained in:
Daniel Imms
2025-11-02 01:21:53 -07:00
parent ceb31bb8f5
commit 80ebe13f31
5 changed files with 21 additions and 12 deletions

View File

@@ -5,8 +5,11 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
declare global {
var testExtensionContext: vscode.ExtensionContext;
}
export function activate(_context: vscode.ExtensionContext) { export function activate(_context: vscode.ExtensionContext) {
// Set context as a global as some tests depend on it // Set context as a global as some tests depend on it
// eslint-disable-next-line local/code-no-any-casts global.testExtensionContext = _context;
(global as any).testExtensionContext = _context;
} }

View File

@@ -178,8 +178,12 @@ suite('chat', () => {
await commands.executeCommand('workbench.action.chat.newChat'); await commands.executeCommand('workbench.action.chat.newChat');
const result = await commands.executeCommand('workbench.action.chat.open', { query: 'hello', blockOnResponse: true }); const result = await commands.executeCommand('workbench.action.chat.open', { query: 'hello', blockOnResponse: true });
// eslint-disable-next-line local/code-no-any-casts type PartialChatAgentResult = {
assert.strictEqual((result as any).errorDetails.code, 'rate_limited'); errorDetails: {
code: string;
};
};
assert.strictEqual((<PartialChatAgentResult>result).errorDetails.code, 'rate_limited');
}); });
test('title provider is called for first request', async () => { test('title provider is called for first request', async () => {

View File

@@ -13,6 +13,12 @@ import * as vscode from 'vscode';
import { Straightforward, Middleware, RequestContext, ConnectContext, isRequest, isConnect } from 'straightforward'; import { Straightforward, Middleware, RequestContext, ConnectContext, isRequest, isConnect } from 'straightforward';
import assert from 'assert'; import assert from 'assert';
declare module 'https' {
interface Agent {
testCertificates?: string[];
}
}
(vscode.env.uiKind === vscode.UIKind.Web ? suite.skip : suite)('vscode API - network proxy support', () => { (vscode.env.uiKind === vscode.UIKind.Web ? suite.skip : suite)('vscode API - network proxy support', () => {
teardown(async function () { teardown(async function () {
@@ -56,8 +62,7 @@ import assert from 'assert';
}); });
// Using https.globalAgent because it is shared with proxyResolver.ts and mutable. // Using https.globalAgent because it is shared with proxyResolver.ts and mutable.
// eslint-disable-next-line local/code-no-any-casts https.globalAgent.testCertificates = [certPEM];
(https.globalAgent as any).testCertificates = [certPEM];
resetCaches(); resetCaches();
try { try {
@@ -73,8 +78,7 @@ import assert from 'assert';
.on('error', reject); .on('error', reject);
}); });
} finally { } finally {
// eslint-disable-next-line local/code-no-any-casts delete https.globalAgent.testCertificates;
delete (https.globalAgent as any).testCertificates;
resetCaches(); resetCaches();
server.close(); server.close();
} }

View File

@@ -13,8 +13,7 @@ suite('vscode API - globalState / workspaceState', () => {
suiteSetup(async () => { suiteSetup(async () => {
// Trigger extension activation and grab the context as some tests depend on it // Trigger extension activation and grab the context as some tests depend on it
await extensions.getExtension('vscode.vscode-api-tests')?.activate(); await extensions.getExtension('vscode.vscode-api-tests')?.activate();
// eslint-disable-next-line local/code-no-any-casts extensionContext = global.testExtensionContext;
extensionContext = (global as any).testExtensionContext;
}); });
test('state basics', async () => { test('state basics', async () => {

View File

@@ -15,8 +15,7 @@ import { assertNoRpc, poll } from '../utils';
suiteSetup(async () => { suiteSetup(async () => {
// Trigger extension activation and grab the context as some tests depend on it // Trigger extension activation and grab the context as some tests depend on it
await extensions.getExtension('vscode.vscode-api-tests')?.activate(); await extensions.getExtension('vscode.vscode-api-tests')?.activate();
// eslint-disable-next-line local/code-no-any-casts extensionContext = global.testExtensionContext;
extensionContext = (global as any).testExtensionContext;
const config = workspace.getConfiguration('terminal.integrated'); const config = workspace.getConfiguration('terminal.integrated');
// Disable conpty in integration tests because of https://github.com/microsoft/vscode/issues/76548 // Disable conpty in integration tests because of https://github.com/microsoft/vscode/issues/76548