mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
debt - start to reduce explicit any in my code (#269479)
This commit is contained in:
@@ -177,6 +177,93 @@ export default tseslint.config(
|
||||
]
|
||||
}
|
||||
},
|
||||
// vscode TS: strict no explicit `any`
|
||||
{
|
||||
files: [
|
||||
'src/vs/base/common/extpath.ts',
|
||||
'src/vs/base/common/glob.ts',
|
||||
'src/vs/base/common/path.ts',
|
||||
'src/vs/base/common/stream.ts',
|
||||
'src/vs/base/node/pfs.ts',
|
||||
'src/vs/base/parts/contextmenu/**',
|
||||
// 'src/vs/base/parts/ipc/**',
|
||||
// 'src/vs/base/parts/sandbox/**',
|
||||
'src/vs/base/parts/storage/**',
|
||||
'src/vs/platform/auxiliaryWindow/**',
|
||||
// 'src/vs/platform/backup/**',
|
||||
// 'src/vs/platform/editor/**',
|
||||
// 'src/vs/platform/environment/**',
|
||||
// 'src/vs/platform/files/**',
|
||||
// 'src/vs/platform/ipc/**',
|
||||
// 'src/vs/platform/launch/**',
|
||||
// 'src/vs/platform/lifecycle/**',
|
||||
// 'src/vs/platform/menubar/**',
|
||||
// 'src/vs/platform/native/**',
|
||||
// 'src/vs/platform/sharedProcess/**',
|
||||
// 'src/vs/platform/state/**',
|
||||
// 'src/vs/platform/storage/**',
|
||||
// 'src/vs/platform/utilityProcess/**',
|
||||
// 'src/vs/platform/window/**',
|
||||
// 'src/vs/platform/windows/**',
|
||||
// 'src/vs/platform/workspace/**',
|
||||
// 'src/vs/platform/workspaces/**',
|
||||
'src/bootstrap-cli.ts',
|
||||
'src/bootstrap-esm.ts',
|
||||
'src/bootstrap-fork.ts',
|
||||
'src/bootstrap-import.ts',
|
||||
'src/bootstrap-meta.ts',
|
||||
'src/bootstrap-node.ts',
|
||||
'src/bootstrap-server.ts',
|
||||
'src/cli.ts',
|
||||
'src/main.ts',
|
||||
'src/server-cli.ts',
|
||||
'src/server-main.ts',
|
||||
'src/vs/code/**',
|
||||
'src/vs/workbench/services/activity/**',
|
||||
'src/vs/workbench/services/auxiliaryWindow/**',
|
||||
'src/vs/workbench/services/chat/**',
|
||||
'src/vs/workbench/services/contextmenu/**',
|
||||
'src/vs/workbench/services/dialogs/**',
|
||||
'src/vs/workbench/services/editor/**',
|
||||
// 'src/vs/workbench/services/environment/**',
|
||||
'src/vs/workbench/services/files/**',
|
||||
'src/vs/workbench/services/filesConfiguration/**',
|
||||
'src/vs/workbench/services/history/**',
|
||||
'src/vs/workbench/services/host/**',
|
||||
'src/vs/workbench/services/label/**',
|
||||
'src/vs/workbench/services/layout/**',
|
||||
'src/vs/workbench/services/lifecycle/**',
|
||||
'src/vs/workbench/services/notification/**',
|
||||
'src/vs/workbench/services/path/**',
|
||||
'src/vs/workbench/services/progress/**',
|
||||
// 'src/vs/workbench/services/storage/**',
|
||||
// 'src/vs/workbench/services/textfile/**',
|
||||
// 'src/vs/workbench/services/textmodelResolver/**',
|
||||
// 'src/vs/workbench/services/untitled/**',
|
||||
// 'src/vs/workbench/services/utilityProcess/**',
|
||||
// 'src/vs/workbench/services/views/**',
|
||||
// 'src/vs/workbench/services/workingCopy/**',
|
||||
// 'src/vs/workbench/services/workspaces/**',
|
||||
// 'src/vs/workbench/common/**',
|
||||
// 'src/vs/workbench/browser/**',
|
||||
// 'src/vs/workbench/electron-browser/**',
|
||||
// 'src/vs/workbench/contrib/files/**',
|
||||
],
|
||||
languageOptions: {
|
||||
parser: tseslint.parser,
|
||||
},
|
||||
plugins: {
|
||||
'@typescript-eslint': tseslint.plugin,
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': [
|
||||
'warn',
|
||||
{
|
||||
'ignoreRestArgs': false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
// Tests
|
||||
{
|
||||
files: [
|
||||
|
||||
@@ -47,7 +47,7 @@ export async function initialize(injectPath: string): Promise<void> {
|
||||
console.log(`[bootstrap-import] Initialized node_modules redirector for: ${injectPath}`);
|
||||
}
|
||||
|
||||
export async function resolve(specifier: string | number, context: any, nextResolve: (arg0: any, arg1: any) => any) {
|
||||
export async function resolve(specifier: string | number, context: unknown, nextResolve: (arg0: unknown, arg1: unknown) => unknown) {
|
||||
|
||||
const newSpecifier = _specifierToUrl[specifier];
|
||||
if (newSpecifier !== undefined) {
|
||||
|
||||
@@ -83,7 +83,7 @@ export function removeGlobalNodeJsModuleLookupPaths(): void {
|
||||
|
||||
const originalResolveLookupPaths = Module._resolveLookupPaths;
|
||||
|
||||
Module._resolveLookupPaths = function (moduleName: string, parent: any): string[] {
|
||||
Module._resolveLookupPaths = function (moduleName: string, parent: unknown): string[] {
|
||||
const paths = originalResolveLookupPaths(moduleName, parent);
|
||||
if (Array.isArray(paths)) {
|
||||
let commonSuffixLength = 0;
|
||||
|
||||
@@ -582,8 +582,7 @@ function registerListeners(): void {
|
||||
* the app-ready event. We listen very early for open-file and remember this upon startup as path to open.
|
||||
*/
|
||||
const macOpenFiles: string[] = [];
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
(globalThis as any)['macOpenFiles'] = macOpenFiles;
|
||||
(globalThis as { macOpenFiles?: string[] }).macOpenFiles = macOpenFiles;
|
||||
app.on('open-file', function (event, path) {
|
||||
macOpenFiles.push(path);
|
||||
});
|
||||
@@ -603,8 +602,7 @@ function registerListeners(): void {
|
||||
app.on('open-url', onOpenUrl);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
(globalThis as any)['getOpenUrls'] = function () {
|
||||
(globalThis as { getOpenUrls?: () => string[] }).getOpenUrls = function () {
|
||||
app.removeListener('open-url', onOpenUrl);
|
||||
|
||||
return openUrls;
|
||||
|
||||
@@ -20,8 +20,7 @@ import { INLSConfiguration } from './vs/nls.js';
|
||||
import { IServerAPI } from './vs/server/node/remoteExtensionHostAgentServer.js';
|
||||
|
||||
perf.mark('code/server/start');
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
(globalThis as any).vscodeServerStartTime = performance.now();
|
||||
(globalThis as { vscodeServerStartTime?: number }).vscodeServerStartTime = performance.now();
|
||||
|
||||
// Do a quick parse to determine if a server or the cli needs to be started
|
||||
const parsedArgs = minimist(process.argv.slice(2), {
|
||||
@@ -139,8 +138,7 @@ if (shouldSpawnCli) {
|
||||
console.log(output);
|
||||
|
||||
perf.mark('code/server/started');
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
(globalThis as any).vscodeServerListenTime = performance.now();
|
||||
(globalThis as { vscodeServerListenTime?: number }).vscodeServerListenTime = performance.now();
|
||||
|
||||
await getRemoteExtensionHostAgentServer();
|
||||
});
|
||||
@@ -153,7 +151,7 @@ if (shouldSpawnCli) {
|
||||
});
|
||||
}
|
||||
|
||||
function sanitizeStringArg(val: any): string | undefined {
|
||||
function sanitizeStringArg(val: unknown): string | undefined {
|
||||
if (Array.isArray(val)) { // if an argument is passed multiple times, minimist creates an array
|
||||
val = val.pop(); // take the last item
|
||||
}
|
||||
|
||||
@@ -331,14 +331,14 @@ class WriteableStreamImpl<T> implements WriteableStream<T> {
|
||||
on(event: 'data', callback: (data: T) => void): void;
|
||||
on(event: 'error', callback: (err: Error) => void): void;
|
||||
on(event: 'end', callback: () => void): void;
|
||||
on(event: 'data' | 'error' | 'end', callback: (arg0?: any) => void): void {
|
||||
on(event: 'data' | 'error' | 'end', callback: ((data: T) => void) | ((err: Error) => void) | (() => void)): void {
|
||||
if (this.state.destroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case 'data':
|
||||
this.listeners.data.push(callback);
|
||||
this.listeners.data.push(callback as (data: T) => void);
|
||||
|
||||
// switch into flowing mode as soon as the first 'data'
|
||||
// listener is added and we are not yet in flowing mode
|
||||
@@ -347,7 +347,7 @@ class WriteableStreamImpl<T> implements WriteableStream<T> {
|
||||
break;
|
||||
|
||||
case 'end':
|
||||
this.listeners.end.push(callback);
|
||||
this.listeners.end.push(callback as () => void);
|
||||
|
||||
// emit 'end' event directly if we are flowing
|
||||
// and the end has already been reached
|
||||
@@ -360,7 +360,7 @@ class WriteableStreamImpl<T> implements WriteableStream<T> {
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
this.listeners.error.push(callback);
|
||||
this.listeners.error.push(callback as (err: Error) => void);
|
||||
|
||||
// emit buffered 'error' events unless done already
|
||||
// now that we know that we have at least one listener
|
||||
|
||||
@@ -13,13 +13,16 @@ export function popup(items: IContextMenuItem[], options?: IPopupOptions, onHide
|
||||
|
||||
const contextMenuId = contextMenuIdPool++;
|
||||
const onClickChannel = `vscode:onContextMenu${contextMenuId}`;
|
||||
const onClickChannelHandler = (event: unknown, itemId: number, context: IContextMenuEvent) => {
|
||||
const onClickChannelHandler = (_event: unknown, ...args: unknown[]) => {
|
||||
const itemId = args[0] as number;
|
||||
const context = args[1] as IContextMenuEvent;
|
||||
const item = processedItems[itemId];
|
||||
item.click?.(context);
|
||||
};
|
||||
|
||||
ipcRenderer.once(onClickChannel, onClickChannelHandler);
|
||||
ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, (event: unknown, closedContextMenuId: number) => {
|
||||
ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, (_event: unknown, ...args: unknown[]) => {
|
||||
const closedContextMenuId = args[0] as number;
|
||||
if (closedContextMenuId !== contextMenuId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,17 +66,17 @@ export interface IpcRenderer {
|
||||
* returned by `invoke` will reject. However, the `Error` object in the renderer
|
||||
* process will not be the same as the one thrown in the main process.
|
||||
*/
|
||||
invoke(channel: string, ...args: any[]): Promise<any>;
|
||||
invoke(channel: string, ...args: unknown[]): Promise<unknown>;
|
||||
/**
|
||||
* Listens to `channel`, when a new message arrives `listener` would be called with
|
||||
* `listener(event, args...)`.
|
||||
*/
|
||||
on(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): this;
|
||||
on(channel: string, listener: (event: IpcRendererEvent, ...args: unknown[]) => void): this;
|
||||
/**
|
||||
* Adds a one time `listener` function for the event. This `listener` is invoked
|
||||
* only the next time a message is sent to `channel`, after which it is removed.
|
||||
*/
|
||||
once(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): this;
|
||||
once(channel: string, listener: (event: IpcRendererEvent, ...args: unknown[]) => void): this;
|
||||
// Note: API with `Transferable` intentionally commented out because you
|
||||
// cannot transfer these when `contextIsolation: true`.
|
||||
// /**
|
||||
@@ -92,12 +92,12 @@ export interface IpcRenderer {
|
||||
// * For more information on using `MessagePort` and `MessageChannel`, see the MDN
|
||||
// * documentation.
|
||||
// */
|
||||
// postMessage(channel: string, message: any, transfer?: MessagePort[]): void;
|
||||
// postMessage(channel: string, message: unknown, transfer?: MessagePort[]): void;
|
||||
/**
|
||||
* Removes the specified `listener` from the listener array for the specified
|
||||
* `channel`.
|
||||
*/
|
||||
removeListener(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): this;
|
||||
removeListener(channel: string, listener: (event: IpcRendererEvent, ...args: unknown[]) => void): this;
|
||||
/**
|
||||
* Send an asynchronous message to the main process via `channel`, along with
|
||||
* arguments. Arguments will be serialized with the Structured Clone Algorithm,
|
||||
@@ -122,7 +122,7 @@ export interface IpcRenderer {
|
||||
* If you want to receive a single response from the main process, like the result
|
||||
* of a method call, consider using `ipcRenderer.invoke`.
|
||||
*/
|
||||
send(channel: string, ...args: any[]): void;
|
||||
send(channel: string, ...args: unknown[]): void;
|
||||
}
|
||||
|
||||
export interface WebFrame {
|
||||
|
||||
@@ -115,8 +115,18 @@ export interface ISandboxContext {
|
||||
resolveConfiguration(): Promise<ISandboxConfiguration>;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
const vscodeGlobal = (globalThis as any).vscode;
|
||||
interface ISandboxGlobal {
|
||||
vscode: {
|
||||
readonly ipcRenderer: IpcRenderer;
|
||||
readonly ipcMessagePort: IpcMessagePort;
|
||||
readonly webFrame: WebFrame;
|
||||
readonly process: ISandboxNodeProcess;
|
||||
readonly context: ISandboxContext;
|
||||
readonly webUtils: WebUtils;
|
||||
};
|
||||
}
|
||||
|
||||
const vscodeGlobal = (globalThis as unknown as ISandboxGlobal).vscode;
|
||||
export const ipcRenderer: IpcRenderer = vscodeGlobal.ipcRenderer;
|
||||
export const ipcMessagePort: IpcMessagePort = vscodeGlobal.ipcMessagePort;
|
||||
export const webFrame: WebFrame = vscodeGlobal.webFrame;
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
*/
|
||||
ipcRenderer: {
|
||||
|
||||
send(channel: string, ...args: any[]): void {
|
||||
send(channel: string, ...args: unknown[]): void {
|
||||
if (validateIPC(channel)) {
|
||||
ipcRenderer.send(channel, ...args);
|
||||
}
|
||||
},
|
||||
|
||||
invoke(channel: string, ...args: any[]): Promise<any> {
|
||||
invoke(channel: string, ...args: unknown[]): Promise<unknown> {
|
||||
validateIPC(channel);
|
||||
|
||||
return ipcRenderer.invoke(channel, ...args);
|
||||
|
||||
@@ -109,19 +109,19 @@
|
||||
|
||||
ipcRenderer: {
|
||||
|
||||
send(channel: string, ...args: any[]): void {
|
||||
send(channel: string, ...args: unknown[]): void {
|
||||
if (validateIPC(channel)) {
|
||||
ipcRenderer.send(channel, ...args);
|
||||
}
|
||||
},
|
||||
|
||||
invoke(channel: string, ...args: any[]): Promise<any> {
|
||||
invoke(channel: string, ...args: unknown[]): Promise<unknown> {
|
||||
validateIPC(channel);
|
||||
|
||||
return ipcRenderer.invoke(channel, ...args);
|
||||
},
|
||||
|
||||
on(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: any[]) => void) {
|
||||
on(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: unknown[]) => void) {
|
||||
validateIPC(channel);
|
||||
|
||||
ipcRenderer.on(channel, listener);
|
||||
@@ -129,7 +129,7 @@
|
||||
return this;
|
||||
},
|
||||
|
||||
once(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: any[]) => void) {
|
||||
once(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: unknown[]) => void) {
|
||||
validateIPC(channel);
|
||||
|
||||
ipcRenderer.once(channel, listener);
|
||||
@@ -137,7 +137,7 @@
|
||||
return this;
|
||||
},
|
||||
|
||||
removeListener(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: any[]) => void) {
|
||||
removeListener(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: unknown[]) => void) {
|
||||
validateIPC(channel);
|
||||
|
||||
ipcRenderer.removeListener(channel, listener);
|
||||
@@ -215,7 +215,7 @@
|
||||
return process.getProcessMemoryInfo();
|
||||
},
|
||||
|
||||
on(type: string, callback: (...args: any[]) => void): void {
|
||||
on(type: string, callback: (...args: unknown[]) => void): void {
|
||||
process.on(type, callback);
|
||||
}
|
||||
},
|
||||
@@ -246,17 +246,10 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Use `contextBridge` APIs to expose globals to VSCode
|
||||
// only if context isolation is enabled, otherwise just
|
||||
// add to the DOM global.
|
||||
if (process.contextIsolated) {
|
||||
try {
|
||||
contextBridge.exposeInMainWorld('vscode', globals);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} else {
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
(window as any).vscode = globals;
|
||||
try {
|
||||
// Use `contextBridge` APIs to expose globals to VSCode
|
||||
contextBridge.exposeInMainWorld('vscode', globals);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}());
|
||||
|
||||
@@ -245,8 +245,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
|
||||
const connection = await this.whenConnected;
|
||||
const row = await this.get(connection, full ? 'PRAGMA integrity_check' : 'PRAGMA quick_check');
|
||||
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
const integrity = full ? (row as any)['integrity_check'] : (row as any)['quick_check'];
|
||||
const integrity = full ? (row as { integrity_check: string }).integrity_check : (row as { quick_check: string }).quick_check;
|
||||
|
||||
if (connection.isErroneous) {
|
||||
return `${integrity} (last error: ${connection.lastError})`;
|
||||
|
||||
@@ -446,7 +446,7 @@ flakySuite('SQLite Storage Library', function () {
|
||||
const corruptDBPath = join(testdir, 'broken.db');
|
||||
await Promises.writeFile(corruptDBPath, 'This is a broken DB');
|
||||
|
||||
let expectedError: any;
|
||||
let expectedError: Error | string | undefined = undefined;
|
||||
await testDBBasics(corruptDBPath, error => {
|
||||
expectedError = error;
|
||||
});
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
type IMainWindowSandboxGlobals = import('../../../base/parts/sandbox/electron-browser/globals.js').IMainWindowSandboxGlobals;
|
||||
type IDesktopMain = import('../../../workbench/electron-browser/desktop.main.js').IDesktopMain;
|
||||
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
const preloadGlobals: IMainWindowSandboxGlobals = (window as any).vscode; // defined by preload.ts
|
||||
const preloadGlobals = (window as unknown as { vscode: IMainWindowSandboxGlobals }).vscode; // defined by preload.ts
|
||||
const safeProcess = preloadGlobals.process;
|
||||
|
||||
//#region Splash Screen Helpers
|
||||
@@ -127,8 +126,7 @@
|
||||
titleDiv.style.left = '0';
|
||||
titleDiv.style.top = '0';
|
||||
titleDiv.style.backgroundColor = `${colorInfo.titleBarBackground}`;
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
(titleDiv.style as any)['-webkit-app-region'] = 'drag';
|
||||
(titleDiv.style as CSSStyleDeclaration & { '-webkit-app-region': string })['-webkit-app-region'] = 'drag';
|
||||
splash.appendChild(titleDiv);
|
||||
|
||||
if (colorInfo.titleBarBorder) {
|
||||
|
||||
@@ -545,8 +545,7 @@ export class CodeApplication extends Disposable {
|
||||
// See: https://github.com/microsoft/vscode/issues/35361#issuecomment-399794085
|
||||
try {
|
||||
if (isMacintosh && this.configurationService.getValue('window.nativeTabs') === true && !systemPreferences.getUserDefault('NSUseImprovedLayoutPass', 'boolean')) {
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
systemPreferences.setUserDefault('NSUseImprovedLayoutPass', 'boolean', true as any);
|
||||
systemPreferences.setUserDefault('NSUseImprovedLayoutPass', 'boolean', true);
|
||||
}
|
||||
} catch (error) {
|
||||
this.logService.error(error);
|
||||
@@ -691,8 +690,7 @@ export class CodeApplication extends Disposable {
|
||||
}
|
||||
|
||||
// macOS: open-url events that were received before the app is ready
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
const protocolUrlsFromEvent = ((<any>global).getOpenUrls() || []) as string[];
|
||||
const protocolUrlsFromEvent = ((global as { getOpenUrls?: () => string[] }).getOpenUrls?.() || []);
|
||||
if (protocolUrlsFromEvent.length > 0) {
|
||||
this.logService.trace(`app#resolveInitialProtocolUrls() protocol urls from macOS 'open-url' event:`, protocolUrlsFromEvent);
|
||||
}
|
||||
@@ -1299,8 +1297,7 @@ export class CodeApplication extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
const macOpenFiles: string[] = (<any>global).macOpenFiles;
|
||||
const macOpenFiles: string[] = (global as { macOpenFiles?: string[] }).macOpenFiles ?? [];
|
||||
const hasCliArgs = args._.length;
|
||||
const hasFolderURIs = !!args['folder-uri'];
|
||||
const hasFileURIs = !!args['file-uri'];
|
||||
|
||||
@@ -40,7 +40,7 @@ function shouldSpawnCliProcess(argv: NativeParsedArgs): boolean {
|
||||
|| !!argv['telemetry'];
|
||||
}
|
||||
|
||||
export async function main(argv: string[]): Promise<any> {
|
||||
export async function main(argv: string[]): Promise<void> {
|
||||
let args: NativeParsedArgs;
|
||||
|
||||
try {
|
||||
@@ -567,7 +567,7 @@ export async function main(argv: string[]): Promise<any> {
|
||||
child = spawn('open', spawnArgs, { ...options, env: {} });
|
||||
}
|
||||
|
||||
return Promise.all(processCallbacks.map(callback => callback(child)));
|
||||
await Promise.all(processCallbacks.map(callback => callback(child)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -609,7 +609,7 @@ class SetupTool extends Disposable implements IToolImpl {
|
||||
return result;
|
||||
}
|
||||
|
||||
async prepareToolInvocation?(parameters: any, token: CancellationToken): Promise<IPreparedToolInvocation | undefined> {
|
||||
async prepareToolInvocation?(parameters: unknown, token: CancellationToken): Promise<IPreparedToolInvocation | undefined> {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,11 @@ class ChatCommandLineHandler extends Disposable {
|
||||
}
|
||||
|
||||
private registerListeners() {
|
||||
ipcRenderer.on('vscode:handleChatRequest', (_, args: typeof this.environmentService.args.chat) => {
|
||||
this.logService.trace('vscode:handleChatRequest', args);
|
||||
ipcRenderer.on('vscode:handleChatRequest', (_, ...args: unknown[]) => {
|
||||
const chatArgs = args[0] as typeof this.environmentService.args.chat;
|
||||
this.logService.trace('vscode:handleChatRequest', chatArgs);
|
||||
|
||||
this.prompt(args);
|
||||
this.prompt(chatArgs);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ class RemoteAgentDiagnosticListener implements IWorkbenchContribution {
|
||||
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
|
||||
@ILabelService labelService: ILabelService
|
||||
) {
|
||||
ipcRenderer.on('vscode:getDiagnosticInfo', (event: unknown, request: { replyChannel: string; args: IDiagnosticInfoOptions }): void => {
|
||||
ipcRenderer.on('vscode:getDiagnosticInfo', (event: unknown, ...args: unknown[]): void => {
|
||||
const request = args[0] as { replyChannel: string; args: IDiagnosticInfoOptions };
|
||||
const connection = remoteAgentService.getConnection();
|
||||
if (connection) {
|
||||
const hostName = labelService.getHostLabel(Schemas.vscodeRemote, connection.remoteAuthority);
|
||||
|
||||
@@ -26,7 +26,7 @@ export class TerminalNativeContribution extends Disposable implements IWorkbench
|
||||
) {
|
||||
super();
|
||||
|
||||
ipcRenderer.on('vscode:openFiles', (_: unknown, request: INativeOpenFileRequest) => { this._onOpenFileRequest(request); });
|
||||
ipcRenderer.on('vscode:openFiles', (_: unknown, ...args: unknown[]) => { this._onOpenFileRequest(args[0] as INativeOpenFileRequest); });
|
||||
this._register(nativeHostService.onDidResumeOS(() => this._onOsResume()));
|
||||
|
||||
this._terminalService.setNativeDelegate({
|
||||
|
||||
@@ -155,7 +155,8 @@ export class NativeWindow extends BaseWindow {
|
||||
}
|
||||
|
||||
// Support `runAction` event
|
||||
ipcRenderer.on('vscode:runAction', async (event: unknown, request: INativeRunActionInWindowRequest) => {
|
||||
ipcRenderer.on('vscode:runAction', async (event: unknown, ...argsRaw: unknown[]) => {
|
||||
const request = argsRaw[0] as INativeRunActionInWindowRequest;
|
||||
const args: unknown[] = request.args || [];
|
||||
|
||||
// If we run an action from the touchbar, we fill in the currently active resource
|
||||
@@ -182,7 +183,8 @@ export class NativeWindow extends BaseWindow {
|
||||
});
|
||||
|
||||
// Support runKeybinding event
|
||||
ipcRenderer.on('vscode:runKeybinding', (event: unknown, request: INativeRunKeybindingInWindowRequest) => {
|
||||
ipcRenderer.on('vscode:runKeybinding', (event: unknown, ...argsRaw: unknown[]) => {
|
||||
const request = argsRaw[0] as INativeRunKeybindingInWindowRequest;
|
||||
const activeElement = getActiveElement();
|
||||
if (activeElement) {
|
||||
this.keybindingService.dispatchByUserSettingsLabel(request.userSettingsLabel, activeElement);
|
||||
@@ -190,7 +192,7 @@ export class NativeWindow extends BaseWindow {
|
||||
});
|
||||
|
||||
// Shared Process crash reported from main
|
||||
ipcRenderer.on('vscode:reportSharedProcessCrash', (event: unknown, error: string) => {
|
||||
ipcRenderer.on('vscode:reportSharedProcessCrash', (event: unknown, ...argsRaw: unknown[]) => {
|
||||
this.notificationService.prompt(
|
||||
Severity.Error,
|
||||
localize('sharedProcessCrash', "A shared background process terminated unexpectedly. Please restart the application to recover."),
|
||||
@@ -205,16 +207,17 @@ export class NativeWindow extends BaseWindow {
|
||||
});
|
||||
|
||||
// Support openFiles event for existing and new files
|
||||
ipcRenderer.on('vscode:openFiles', (event: unknown, request: IOpenFileRequest) => { this.onOpenFiles(request); });
|
||||
ipcRenderer.on('vscode:openFiles', (event: unknown, ...argsRaw: unknown[]) => { this.onOpenFiles(argsRaw[0] as IOpenFileRequest); });
|
||||
|
||||
// Support addRemoveFolders event for workspace management
|
||||
ipcRenderer.on('vscode:addRemoveFolders', (event: unknown, request: IAddRemoveFoldersRequest) => this.onAddRemoveFoldersRequest(request));
|
||||
ipcRenderer.on('vscode:addRemoveFolders', (event: unknown, ...argsRaw: unknown[]) => this.onAddRemoveFoldersRequest(argsRaw[0] as IAddRemoveFoldersRequest));
|
||||
|
||||
// Message support
|
||||
ipcRenderer.on('vscode:showInfoMessage', (event: unknown, message: string) => this.notificationService.info(message));
|
||||
ipcRenderer.on('vscode:showInfoMessage', (event: unknown, ...argsRaw: unknown[]) => this.notificationService.info(argsRaw[0] as string));
|
||||
|
||||
// Shell Environment Issue Notifications
|
||||
ipcRenderer.on('vscode:showResolveShellEnvError', (event: unknown, message: string) => {
|
||||
ipcRenderer.on('vscode:showResolveShellEnvError', (event: unknown, ...argsRaw: unknown[]) => {
|
||||
const message = argsRaw[0] as string;
|
||||
this.notificationService.prompt(
|
||||
Severity.Error,
|
||||
message,
|
||||
@@ -233,7 +236,8 @@ export class NativeWindow extends BaseWindow {
|
||||
);
|
||||
});
|
||||
|
||||
ipcRenderer.on('vscode:showCredentialsError', (event: unknown, message: string) => {
|
||||
ipcRenderer.on('vscode:showCredentialsError', (event: unknown, ...argsRaw: unknown[]) => {
|
||||
const message = argsRaw[0] as string;
|
||||
this.notificationService.prompt(
|
||||
Severity.Error,
|
||||
localize('keychainWriteError', "Writing login information to the keychain failed with error '{0}'.", message),
|
||||
@@ -263,7 +267,7 @@ export class NativeWindow extends BaseWindow {
|
||||
);
|
||||
});
|
||||
|
||||
ipcRenderer.on('vscode:showArgvParseWarning', (event: unknown, message: string) => {
|
||||
ipcRenderer.on('vscode:showArgvParseWarning', () => {
|
||||
this.notificationService.prompt(
|
||||
Severity.Warning,
|
||||
localize("showArgvParseWarning", "The runtime arguments file 'argv.json' contains errors. Please correct them and restart."),
|
||||
@@ -282,7 +286,8 @@ export class NativeWindow extends BaseWindow {
|
||||
ipcRenderer.on('vscode:leaveFullScreen', () => setFullscreen(false, mainWindow));
|
||||
|
||||
// Proxy Login Dialog
|
||||
ipcRenderer.on('vscode:openProxyAuthenticationDialog', async (event: unknown, payload: { authInfo: AuthInfo; username?: string; password?: string; replyChannel: string }) => {
|
||||
ipcRenderer.on('vscode:openProxyAuthenticationDialog', async (event: unknown, ...argsRaw: unknown[]) => {
|
||||
const payload = argsRaw[0] as { authInfo: AuthInfo; username?: string; password?: string; replyChannel: string };
|
||||
const rememberCredentialsKey = 'window.rememberProxyCredentials';
|
||||
const rememberCredentials = this.storageService.getBoolean(rememberCredentialsKey, StorageScope.APPLICATION);
|
||||
const result = await this.dialogService.input({
|
||||
@@ -324,12 +329,14 @@ export class NativeWindow extends BaseWindow {
|
||||
});
|
||||
|
||||
// Accessibility support changed event
|
||||
ipcRenderer.on('vscode:accessibilitySupportChanged', (event: unknown, accessibilitySupportEnabled: boolean) => {
|
||||
ipcRenderer.on('vscode:accessibilitySupportChanged', (event: unknown, ...argsRaw: unknown[]) => {
|
||||
const accessibilitySupportEnabled = argsRaw[0] as boolean;
|
||||
this.accessibilityService.setAccessibilitySupport(accessibilitySupportEnabled ? AccessibilitySupport.Enabled : AccessibilitySupport.Disabled);
|
||||
});
|
||||
|
||||
// Allow to update security settings around allowed UNC Host
|
||||
ipcRenderer.on('vscode:configureAllowedUNCHost', async (event: unknown, host: string) => {
|
||||
ipcRenderer.on('vscode:configureAllowedUNCHost', async (event: unknown, ...argsRaw: unknown[]) => {
|
||||
const host = argsRaw[0] as string;
|
||||
if (!isWindows) {
|
||||
return; // only supported on Windows
|
||||
}
|
||||
@@ -354,7 +361,8 @@ export class NativeWindow extends BaseWindow {
|
||||
});
|
||||
|
||||
// Allow to update security settings around protocol handlers
|
||||
ipcRenderer.on('vscode:disablePromptForProtocolHandling', (event: unknown, kind: 'local' | 'remote') => {
|
||||
ipcRenderer.on('vscode:disablePromptForProtocolHandling', (event: unknown, ...argsRaw: unknown[]) => {
|
||||
const kind = argsRaw[0] as 'local' | 'remote';
|
||||
const setting = kind === 'local' ? 'security.promptForLocalFileProtocolHandling' : 'security.promptForRemoteFileProtocolHandling';
|
||||
this.configurationService.updateValue(setting, false);
|
||||
});
|
||||
|
||||
@@ -70,16 +70,16 @@ export interface IBadgeStyles {
|
||||
readonly badgeBorder: Color | undefined;
|
||||
}
|
||||
|
||||
class BaseBadge implements IBadge {
|
||||
class BaseBadge<T = unknown> implements IBadge {
|
||||
|
||||
constructor(
|
||||
protected readonly descriptorFn: (arg: any) => string,
|
||||
protected readonly descriptorFn: (arg: T) => string,
|
||||
private readonly stylesFn: ((theme: IColorTheme) => IBadgeStyles | undefined) | undefined,
|
||||
) {
|
||||
}
|
||||
|
||||
getDescription(): string {
|
||||
return this.descriptorFn(null);
|
||||
return this.descriptorFn(null as T);
|
||||
}
|
||||
|
||||
getColors(theme: IColorTheme): IBadgeStyles | undefined {
|
||||
@@ -87,7 +87,7 @@ class BaseBadge implements IBadge {
|
||||
}
|
||||
}
|
||||
|
||||
export class NumberBadge extends BaseBadge {
|
||||
export class NumberBadge extends BaseBadge<number> {
|
||||
|
||||
constructor(readonly number: number, descriptorFn: (num: number) => string) {
|
||||
super(descriptorFn, undefined);
|
||||
@@ -100,7 +100,7 @@ export class NumberBadge extends BaseBadge {
|
||||
}
|
||||
}
|
||||
|
||||
export class IconBadge extends BaseBadge {
|
||||
export class IconBadge extends BaseBadge<void> {
|
||||
constructor(
|
||||
readonly icon: ThemeIcon,
|
||||
descriptorFn: () => string,
|
||||
@@ -110,7 +110,7 @@ export class IconBadge extends BaseBadge {
|
||||
}
|
||||
}
|
||||
|
||||
export class ProgressBadge extends BaseBadge {
|
||||
export class ProgressBadge extends BaseBadge<void> {
|
||||
constructor(descriptorFn: () => string) {
|
||||
super(descriptorFn, undefined);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import { getZoomLevel, isFullscreen, setFullscreen } from '../../../../base/brow
|
||||
import { getActiveWindow } from '../../../../base/browser/dom.js';
|
||||
import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';
|
||||
import { isMacintosh } from '../../../../base/common/platform.js';
|
||||
import { assert } from '../../../../base/common/assert.js';
|
||||
import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js';
|
||||
|
||||
type NativeCodeWindow = CodeWindow & {
|
||||
@@ -156,6 +157,7 @@ export class NativeAuxiliaryWindowService extends BrowserAuxiliaryWindowService
|
||||
mark('code/auxiliaryWindow/willResolveWindowId');
|
||||
const windowId = await auxiliaryWindow.vscode.ipcRenderer.invoke('vscode:registerAuxiliaryWindow', this.nativeHostService.windowId);
|
||||
mark('code/auxiliaryWindow/didResolveWindowId');
|
||||
assert(typeof windowId === 'number');
|
||||
|
||||
return windowId;
|
||||
}
|
||||
|
||||
@@ -159,10 +159,10 @@ export class CustomEditorLabelService extends Disposable implements ICustomEdito
|
||||
private readonly _filenameCaptureExpression = /(?<filename>^\.*[^.]*)/;
|
||||
private applyTemplate(template: string, resource: URI, relevantPath: string): string {
|
||||
let parsedPath: undefined | ParsedPath;
|
||||
return template.replace(this._parsedTemplateExpression, (match: string, variable: string, ...args: any[]) => {
|
||||
return template.replace(this._parsedTemplateExpression, (match: string, variable: string, ...args: unknown[]) => {
|
||||
parsedPath = parsedPath ?? parsePath(resource.path);
|
||||
// named group matches
|
||||
const { dirnameN = '0', extnameN = '0' }: { dirnameN?: string; extnameN?: string } = args.pop();
|
||||
const { dirnameN = '0', extnameN = '0' } = args.pop() as { dirnameN?: string; extnameN?: string };
|
||||
|
||||
if (variable === 'filename') {
|
||||
const { filename } = this._filenameCaptureExpression.exec(parsedPath.base)?.groups ?? {};
|
||||
|
||||
@@ -33,7 +33,7 @@ suite('Custom Editor Label Service', () => {
|
||||
return [customLabelService, configService, instantiationService.createInstance(TestServiceAccessor)];
|
||||
}
|
||||
|
||||
async function updatePattern(configService: TestConfigurationService, value: any): Promise<void> {
|
||||
async function updatePattern(configService: TestConfigurationService, value: unknown): Promise<void> {
|
||||
await configService.setUserConfiguration(CustomEditorLabelService.SETTING_ID_PATTERNS, value);
|
||||
configService.onDidChangeConfigurationEmitter.fire({
|
||||
affectsConfiguration: (key: string) => key === CustomEditorLabelService.SETTING_ID_PATTERNS,
|
||||
|
||||
@@ -538,16 +538,25 @@ export class BrowserHostService extends Disposable implements IHostService {
|
||||
}
|
||||
|
||||
// Safari and Edge 14 are all using webkit prefix
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
if ((<any>targetWindow.document).webkitIsFullScreen !== undefined) {
|
||||
|
||||
interface WebkitDocument extends Document {
|
||||
webkitFullscreenElement: Element | null;
|
||||
webkitExitFullscreen(): Promise<void>;
|
||||
webkitIsFullScreen: boolean;
|
||||
}
|
||||
|
||||
interface WebkitHTMLElement extends HTMLElement {
|
||||
webkitRequestFullscreen(): Promise<void>;
|
||||
}
|
||||
|
||||
const webkitDocument = targetWindow.document as WebkitDocument;
|
||||
const webkitElement = target as WebkitHTMLElement;
|
||||
if (webkitDocument.webkitIsFullScreen !== undefined) {
|
||||
try {
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
if (!(<any>targetWindow.document).webkitIsFullScreen) {
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
(<any>target).webkitRequestFullscreen(); // it's async, but doesn't return a real promise.
|
||||
if (!webkitDocument.webkitIsFullScreen) {
|
||||
webkitElement.webkitRequestFullscreen(); // it's async, but doesn't return a real promise
|
||||
} else {
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
(<any>targetWindow.document).webkitExitFullscreen(); // it's async, but doesn't return a real promise.
|
||||
webkitDocument.webkitExitFullscreen(); // it's async, but doesn't return a real promise
|
||||
}
|
||||
} catch {
|
||||
this.logService.warn('toggleFullScreen(): requestFullscreen/exitFullscreen failed');
|
||||
|
||||
@@ -222,8 +222,7 @@ suite('URI Label', () => {
|
||||
}
|
||||
assert.deepStrictEqual(m, { formatters: expected });
|
||||
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
delete (m as any).formatters;
|
||||
delete (m as { formatters: unknown }).formatters;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ export class NativeLifecycleService extends AbstractLifecycleService {
|
||||
const windowId = this.nativeHostService.windowId;
|
||||
|
||||
// Main side indicates that window is about to unload, check for vetos
|
||||
ipcRenderer.on('vscode:onBeforeUnload', async (event: unknown, reply: { okChannel: string; cancelChannel: string; reason: ShutdownReason }) => {
|
||||
ipcRenderer.on('vscode:onBeforeUnload', async (event: unknown, ...args: unknown[]) => {
|
||||
const reply = args[0] as { okChannel: string; cancelChannel: string; reason: ShutdownReason };
|
||||
this.logService.trace(`[lifecycle] onBeforeUnload (reason: ${reply.reason})`);
|
||||
|
||||
// trigger onBeforeShutdown events and veto collecting
|
||||
@@ -60,7 +61,8 @@ export class NativeLifecycleService extends AbstractLifecycleService {
|
||||
});
|
||||
|
||||
// Main side indicates that we will indeed shutdown
|
||||
ipcRenderer.on('vscode:onWillUnload', async (event: unknown, reply: { replyChannel: string; reason: ShutdownReason }) => {
|
||||
ipcRenderer.on('vscode:onWillUnload', async (event: unknown, ...args: unknown[]) => {
|
||||
const reply = args[0] as { replyChannel: string; reason: ShutdownReason };
|
||||
this.logService.trace(`[lifecycle] onWillUnload (reason: ${reply.reason})`);
|
||||
|
||||
// trigger onWillShutdown events and joining
|
||||
|
||||
@@ -7,32 +7,33 @@ import assert from 'assert';
|
||||
import { DisposableStore } from '../../../../../base/common/lifecycle.js';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';
|
||||
import { AbstractProgressScope, ScopedProgressIndicator } from '../../browser/progressIndicator.js';
|
||||
import { ProgressBar } from '../../../../../base/browser/ui/progressbar/progressbar.js';
|
||||
|
||||
class TestProgressBar {
|
||||
class TestProgressBar extends ProgressBar {
|
||||
fTotal: number = 0;
|
||||
fWorked: number = 0;
|
||||
fInfinite: boolean = false;
|
||||
fDone: boolean = false;
|
||||
|
||||
infinite() {
|
||||
override infinite() {
|
||||
this.fDone = null!;
|
||||
this.fInfinite = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
total(total: number) {
|
||||
override total(total: number) {
|
||||
this.fDone = null!;
|
||||
this.fTotal = total;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
hasTotal() {
|
||||
override hasTotal() {
|
||||
return !!this.fTotal;
|
||||
}
|
||||
|
||||
worked(worked: number) {
|
||||
override worked(worked: number) {
|
||||
this.fDone = null!;
|
||||
|
||||
if (this.fWorked) {
|
||||
@@ -44,7 +45,7 @@ class TestProgressBar {
|
||||
return this;
|
||||
}
|
||||
|
||||
done() {
|
||||
override done() {
|
||||
this.fDone = true;
|
||||
|
||||
this.fInfinite = null!;
|
||||
@@ -54,13 +55,13 @@ class TestProgressBar {
|
||||
return this;
|
||||
}
|
||||
|
||||
stop() {
|
||||
override stop() {
|
||||
return this.done();
|
||||
}
|
||||
|
||||
show(): void { }
|
||||
override show(): void { }
|
||||
|
||||
hide(): void { }
|
||||
override hide(): void { }
|
||||
}
|
||||
|
||||
suite('Progress Indicator', () => {
|
||||
@@ -72,14 +73,13 @@ suite('Progress Indicator', () => {
|
||||
});
|
||||
|
||||
test('ScopedProgressIndicator', async () => {
|
||||
const testProgressBar = new TestProgressBar();
|
||||
const testProgressBar = disposables.add(new TestProgressBar(document.createElement('div')));
|
||||
const progressScope = disposables.add(new class extends AbstractProgressScope {
|
||||
constructor() { super('test.scopeId', true); }
|
||||
testOnScopeOpened(scopeId: string) { super.onScopeOpened(scopeId); }
|
||||
testOnScopeClosed(scopeId: string): void { super.onScopeClosed(scopeId); }
|
||||
}());
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
const testObject = disposables.add(new ScopedProgressIndicator((<any>testProgressBar), progressScope));
|
||||
const testObject = disposables.add(new ScopedProgressIndicator(testProgressBar, progressScope));
|
||||
|
||||
// Active: Show (Infinite)
|
||||
let fn = testObject.show(true);
|
||||
|
||||
Reference in New Issue
Block a user