mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
remove any type usage (#277367)
This commit is contained in:
committed by
GitHub
parent
e45d218720
commit
81f93f42f7
@@ -507,7 +507,6 @@ export default tseslint.config(
|
||||
'src/vs/platform/userDataSync/common/userDataSyncIpc.ts',
|
||||
'src/vs/platform/userDataSync/common/userDataSyncServiceIpc.ts',
|
||||
'src/vs/platform/webview/common/webviewManagerService.ts',
|
||||
'src/vs/platform/configuration/test/common/testConfigurationService.ts',
|
||||
'src/vs/platform/instantiation/test/common/instantiationServiceMock.ts',
|
||||
'src/vs/platform/keybinding/test/common/mockKeybindingService.ts',
|
||||
// Editor
|
||||
@@ -556,7 +555,6 @@ export default tseslint.config(
|
||||
'src/vs/workbench/api/common/extHostChatSessions.ts',
|
||||
'src/vs/workbench/api/common/extHostCodeInsets.ts',
|
||||
'src/vs/workbench/api/common/extHostCommands.ts',
|
||||
'src/vs/workbench/api/common/extHostConfiguration.ts',
|
||||
'src/vs/workbench/api/common/extHostConsoleForwarder.ts',
|
||||
'src/vs/workbench/api/common/extHostDataChannels.ts',
|
||||
'src/vs/workbench/api/common/extHostDebugService.ts',
|
||||
@@ -807,8 +805,6 @@ export default tseslint.config(
|
||||
'src/vs/workbench/services/commands/common/commandService.ts',
|
||||
'src/vs/workbench/services/configurationResolver/common/configurationResolver.ts',
|
||||
'src/vs/workbench/services/configurationResolver/common/configurationResolverExpression.ts',
|
||||
'src/vs/workbench/services/extensionManagement/browser/builtinExtensionsScannerService.ts',
|
||||
'src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts',
|
||||
'src/vs/workbench/services/extensions/common/extensionHostManager.ts',
|
||||
'src/vs/workbench/services/extensions/common/extensionsRegistry.ts',
|
||||
'src/vs/workbench/services/extensions/common/lazyPromise.ts',
|
||||
|
||||
@@ -8,7 +8,7 @@ import { join } from '../../../../base/common/path.js';
|
||||
import { URI } from '../../../../base/common/uri.js';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js';
|
||||
import { Configuration, ConfigurationChangeEvent, ConfigurationModel, ConfigurationModelParser, mergeChanges } from '../../common/configurationModels.js';
|
||||
import { IConfigurationRegistry, Extensions, ConfigurationScope } from '../../common/configurationRegistry.js';
|
||||
import { IConfigurationRegistry, Extensions, ConfigurationScope, IConfigurationNode } from '../../common/configurationRegistry.js';
|
||||
import { NullLogService } from '../../../log/common/log.js';
|
||||
import { Registry } from '../../../registry/common/platform.js';
|
||||
import { WorkspaceFolder } from '../../../workspace/common/workspace.js';
|
||||
@@ -107,7 +107,7 @@ suite('ConfigurationModelParser - Excluded Properties', () => {
|
||||
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
|
||||
|
||||
let testConfigurationNodes: any[] = [];
|
||||
let testConfigurationNodes: IConfigurationNode[] = [];
|
||||
|
||||
setup(() => reset());
|
||||
teardown(() => reset());
|
||||
@@ -393,11 +393,11 @@ suite('ConfigurationModel', () => {
|
||||
|
||||
testObject.setValue('b.c', 1);
|
||||
|
||||
const expected: any = {};
|
||||
const expected: Record<string, unknown> = {};
|
||||
expected['a'] = { 'b': 1 };
|
||||
expected['f'] = 1;
|
||||
expected['b'] = Object.create(null);
|
||||
expected['b']['c'] = 1;
|
||||
(expected['b'] as Record<string, unknown>)['c'] = 1;
|
||||
assert.deepStrictEqual(testObject.contents, expected);
|
||||
assert.deepStrictEqual(testObject.keys, ['a.b', 'f', 'b.c']);
|
||||
});
|
||||
@@ -508,8 +508,7 @@ suite('ConfigurationModel', () => {
|
||||
test('get overriding configuration if the value of overriding identifier is not object', () => {
|
||||
const testObject = new ConfigurationModel(
|
||||
{ 'a': { 'b': 1 }, 'f': { 'g': 1 } }, [],
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
[{ identifiers: ['c'], contents: 'abc' as any, keys: [] }], [], new NullLogService());
|
||||
[{ identifiers: ['c'], contents: 'abc' as unknown as Record<string, unknown>, keys: [] }], [], new NullLogService());
|
||||
|
||||
assert.deepStrictEqual(testObject.override('c').contents, { 'a': { 'b': 1 }, 'f': { 'g': 1 } });
|
||||
});
|
||||
@@ -993,7 +992,7 @@ suite('Configuration', () => {
|
||||
|
||||
});
|
||||
|
||||
function parseConfigurationModel(content: any): ConfigurationModel {
|
||||
function parseConfigurationModel(content: Record<string, unknown>): ConfigurationModel {
|
||||
const parser = new ConfigurationModelParser('test', new NullLogService());
|
||||
parser.parse(JSON.stringify(content));
|
||||
return parser.configurationModel;
|
||||
@@ -1602,7 +1601,7 @@ suite('Configuration.Parse', () => {
|
||||
|
||||
});
|
||||
|
||||
function toConfigurationModel(obj: any): ConfigurationModel {
|
||||
function toConfigurationModel(obj: Record<string, unknown>): ConfigurationModel {
|
||||
const parser = new ConfigurationModelParser('test', new NullLogService());
|
||||
parser.parse(JSON.stringify(obj));
|
||||
return parser.configurationModel;
|
||||
|
||||
@@ -13,21 +13,21 @@ import { Registry } from '../../../registry/common/platform.js';
|
||||
export class TestConfigurationService implements IConfigurationService {
|
||||
public _serviceBrand: undefined;
|
||||
|
||||
private configuration: any;
|
||||
private configuration: Record<string, unknown>;
|
||||
readonly onDidChangeConfigurationEmitter = new Emitter<IConfigurationChangeEvent>();
|
||||
readonly onDidChangeConfiguration = this.onDidChangeConfigurationEmitter.event;
|
||||
|
||||
constructor(configuration?: any) {
|
||||
constructor(configuration?: Record<string, unknown>) {
|
||||
this.configuration = configuration || Object.create(null);
|
||||
}
|
||||
|
||||
private configurationByRoot: TernarySearchTree<string, any> = TernarySearchTree.forPaths<any>();
|
||||
private configurationByRoot: TernarySearchTree<string, Record<string, unknown>> = TernarySearchTree.forPaths<Record<string, unknown>>();
|
||||
|
||||
public reloadConfiguration<T>(): Promise<T> {
|
||||
return Promise.resolve(this.getValue());
|
||||
return Promise.resolve(this.getValue() as T);
|
||||
}
|
||||
|
||||
public getValue(arg1?: any, arg2?: any): any {
|
||||
public getValue<T>(arg1?: string | IConfigurationOverrides, arg2?: IConfigurationOverrides): T | undefined {
|
||||
let configuration;
|
||||
const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : undefined;
|
||||
if (overrides) {
|
||||
@@ -37,16 +37,16 @@ export class TestConfigurationService implements IConfigurationService {
|
||||
}
|
||||
configuration = configuration ? configuration : this.configuration;
|
||||
if (arg1 && typeof arg1 === 'string') {
|
||||
return configuration[arg1] ?? getConfigurationValue(configuration, arg1);
|
||||
return (configuration[arg1] ?? getConfigurationValue(configuration, arg1)) as T;
|
||||
}
|
||||
return configuration;
|
||||
return configuration as T;
|
||||
}
|
||||
|
||||
public updateValue(key: string, value: any): Promise<void> {
|
||||
public updateValue(key: string, value: unknown): Promise<void> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public setUserConfiguration(key: any, value: any, root?: URI): Promise<void> {
|
||||
public setUserConfiguration(key: string, value: unknown, root?: URI): Promise<void> {
|
||||
if (root) {
|
||||
const configForRoot = this.configurationByRoot.get(root.fsPath) || Object.create(null);
|
||||
configForRoot[key] = value;
|
||||
@@ -64,7 +64,7 @@ export class TestConfigurationService implements IConfigurationService {
|
||||
}
|
||||
|
||||
public inspect<T>(key: string, overrides?: IConfigurationOverrides): IConfigurationValue<T> {
|
||||
const value = this.getValue(key, overrides);
|
||||
const value = this.getValue(key, overrides) as T;
|
||||
|
||||
return {
|
||||
value,
|
||||
|
||||
@@ -725,8 +725,8 @@ suite('TelemetryService', () => {
|
||||
appenders: [testAppender]
|
||||
}, new class extends TestConfigurationService {
|
||||
override onDidChangeConfiguration = emitter.event;
|
||||
override getValue() {
|
||||
return telemetryLevel;
|
||||
override getValue<T>(): T {
|
||||
return telemetryLevel as T;
|
||||
}
|
||||
}(), TestProductService);
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ function mockNotebookService(notebook: NotebookTextModel, notebookSerializer: Pr
|
||||
override async createNotebookTextDocumentSnapshot(uri: URI, context: SnapshotContext, token: CancellationToken): Promise<VSBufferReadableStream> {
|
||||
const info = await this.withNotebookDataProvider(notebook.viewType);
|
||||
const serializer = info.serializer;
|
||||
const outputSizeLimit = configurationService.getValue(NotebookSetting.outputBackupSizeLimit) ?? 1024;
|
||||
const outputSizeLimit = configurationService.getValue<number>(NotebookSetting.outputBackupSizeLimit) ?? 1024;
|
||||
const data: NotebookData = notebook.createSnapshot({ context: context, outputSizeLimit: outputSizeLimit, transientOptions: serializer.options });
|
||||
const bytes = await serializer.notebookToData(data);
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ suite('Workspace Configuration', () => {
|
||||
|
||||
});
|
||||
|
||||
function toConfigurationModel(obj: any): ConfigurationModel {
|
||||
function toConfigurationModel(obj: Record<string, unknown>): ConfigurationModel {
|
||||
const parser = new ConfigurationModelParser('test', new NullLogService());
|
||||
parser.parse(JSON.stringify(obj));
|
||||
return parser.configurationModel;
|
||||
|
||||
@@ -20,7 +20,7 @@ import { mainWindow } from '../../../../base/browser/window.js';
|
||||
interface IBundledExtension {
|
||||
extensionPath: string;
|
||||
packageJSON: IExtensionManifest;
|
||||
packageNLS?: any;
|
||||
packageNLS?: ITranslations;
|
||||
readmePath?: string;
|
||||
changelogPath?: string;
|
||||
}
|
||||
|
||||
@@ -54,14 +54,13 @@ function isGalleryExtensionInfo(obj: unknown): obj is GalleryExtensionInfo {
|
||||
&& (galleryExtensionInfo.migrateStorageFrom === undefined || typeof galleryExtensionInfo.migrateStorageFrom === 'string');
|
||||
}
|
||||
|
||||
function isUriComponents(thing: unknown): thing is UriComponents {
|
||||
if (!thing) {
|
||||
function isUriComponents(obj: unknown): obj is UriComponents {
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
return isString((<any>thing).path) &&
|
||||
// eslint-disable-next-line local/code-no-any-casts
|
||||
isString((<any>thing).scheme);
|
||||
const thing = obj as UriComponents | undefined;
|
||||
return typeof thing?.path === 'string' &&
|
||||
typeof thing?.scheme === 'string';
|
||||
}
|
||||
|
||||
interface IStoredWebExtension {
|
||||
|
||||
@@ -41,6 +41,7 @@ import { IFileService } from '../../../../../platform/files/common/files.js';
|
||||
import { FileService } from '../../../../../platform/files/common/fileService.js';
|
||||
import { IProductService } from '../../../../../platform/product/common/productService.js';
|
||||
import { AllowedExtensionsService } from '../../../../../platform/extensionManagement/common/allowedExtensionsService.js';
|
||||
import { IStringDictionary } from '../../../../../base/common/collections.js';
|
||||
|
||||
function createStorageService(instantiationService: TestInstantiationService, disposableStore: DisposableStore): IStorageService {
|
||||
let service = instantiationService.get(IStorageService);
|
||||
@@ -1241,7 +1242,7 @@ function aLocalExtension(id: string, contributes?: IExtensionContributions, type
|
||||
return aLocalExtension2(id, contributes ? { contributes } : {}, isUndefinedOrNull(type) ? {} : { type });
|
||||
}
|
||||
|
||||
function aLocalExtension2(id: string, manifest: Partial<IExtensionManifest> = {}, properties: any = {}): ILocalExtension {
|
||||
function aLocalExtension2(id: string, manifest: Partial<IExtensionManifest> = {}, properties: IStringDictionary<unknown> = {}): ILocalExtension {
|
||||
const [publisher, name] = id.split('.');
|
||||
manifest = { name, publisher, ...manifest };
|
||||
properties = {
|
||||
|
||||
@@ -20,12 +20,12 @@ suite('Breadcrumb Model', function () {
|
||||
let model: BreadcrumbsModel;
|
||||
const workspaceService = new TestContextService(new Workspace('ffff', [new WorkspaceFolder({ uri: URI.parse('foo:/bar/baz/ws'), name: 'ws', index: 0 })]));
|
||||
const configService = new class extends TestConfigurationService {
|
||||
override getValue(...args: any[]) {
|
||||
override getValue<T>(...args: any[]): T | undefined {
|
||||
if (args[0] === 'breadcrumbs.filePath') {
|
||||
return 'on';
|
||||
return 'on' as T;
|
||||
}
|
||||
if (args[0] === 'breadcrumbs.symbolPath') {
|
||||
return 'on';
|
||||
return 'on' as T;
|
||||
}
|
||||
return super.getValue(...args);
|
||||
}
|
||||
|
||||
@@ -1312,7 +1312,7 @@ export class TestTextResourceConfigurationService implements ITextResourceConfig
|
||||
getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
|
||||
const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;
|
||||
const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
|
||||
return this.configurationService.getValue(section, { resource });
|
||||
return this.configurationService.getValue(section, { resource }) as T;
|
||||
}
|
||||
|
||||
inspect<T>(resource: URI | undefined, position: IPosition | null, section: string): IConfigurationValue<Readonly<T>> {
|
||||
|
||||
Reference in New Issue
Block a user