remove some any casts that aren't needed (anymore) (#166557)

This commit is contained in:
Johannes Rieken
2022-11-17 09:58:12 +01:00
committed by GitHub
parent 562b3dbd54
commit f675b2bfab
9 changed files with 22 additions and 20 deletions

View File

@@ -224,3 +224,11 @@ export type AddFirstParameterToFunctions<Target, TargetFunctionsReturnType, Firs
* i.e. AtLeastOne<MyObject>;
*/
export type AtLeastOne<T, U = { [K in keyof T]: Pick<T, K> }> = Partial<T> & U[keyof U];
/**
* A type that removed readonly-less from all properties of `T`
*/
export type Mutable<T> = {
-readonly [P in keyof T]: T[P]
};

View File

@@ -61,7 +61,7 @@ export function ensureValidWordDefinition(wordDefinition?: RegExp | null): RegEx
if (wordDefinition.multiline) {
flags += 'm';
}
if ((wordDefinition as any).unicode) {
if (wordDefinition.unicode) {
flags += 'u';
}
result = new RegExp(wordDefinition.source, flags);

View File

@@ -97,9 +97,7 @@ export class RemoteAuthorityResolverError extends ErrorNoTelemetry {
// workaround when extending builtin objects and when compiling to ES5, see:
// https://github.com/microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
if (typeof (<any>Object).setPrototypeOf === 'function') {
(<any>Object).setPrototypeOf(this, RemoteAuthorityResolverError.prototype);
}
Object.setPrototypeOf(this, RemoteAuthorityResolverError.prototype);
}
}

View File

@@ -515,9 +515,7 @@ export class RemoteAuthorityResolverError extends Error {
// workaround when extending builtin objects and when compiling to ES5, see:
// https://github.com/microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
if (typeof (<any>Object).setPrototypeOf === 'function') {
(<any>Object).setPrototypeOf(this, RemoteAuthorityResolverError.prototype);
}
Object.setPrototypeOf(this, RemoteAuthorityResolverError.prototype);
}
}
@@ -2954,9 +2952,7 @@ export class FileSystemError extends Error {
// workaround when extending builtin objects and when compiling to ES5, see:
// https://github.com/microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
if (typeof (<any>Object).setPrototypeOf === 'function') {
(<any>Object).setPrototypeOf(this, FileSystemError.prototype);
}
Object.setPrototypeOf(this, FileSystemError.prototype);
if (typeof Error.captureStackTrace === 'function' && typeof terminator === 'function') {
// nice stack traces

View File

@@ -11,7 +11,7 @@ import { IMessagePassingProtocol } from 'vs/base/parts/ipc/common/ipc';
import { MainContext, MainThreadConsoleShape } from 'vs/workbench/api/common/extHost.protocol';
import { IExtensionHostInitData } from 'vs/workbench/services/extensions/common/extensionHostProtocol';
import { RPCProtocol } from 'vs/workbench/services/extensions/common/rpcProtocol';
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ExtensionIdentifier, IExtensionDescription, IRelaxedExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ILogService } from 'vs/platform/log/common/log';
import { getSingletonServiceDescriptors } from 'vs/platform/instantiation/common/extensions';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
@@ -22,6 +22,7 @@ import { IExtHostRpcService, ExtHostRpcService } from 'vs/workbench/api/common/e
import { IURITransformerService, URITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
import { IExtHostExtensionService, IHostUtils } from 'vs/workbench/api/common/extHostExtensionService';
import { IExtHostTelemetry } from 'vs/workbench/api/common/extHostTelemetry';
import { Mutable } from 'vs/base/common/types';
export interface IExitFn {
(code?: number): any;
@@ -163,11 +164,11 @@ export class ExtensionHostMain {
private static _transform(initData: IExtensionHostInitData, rpcProtocol: RPCProtocol): IExtensionHostInitData {
initData.allExtensions.forEach((ext) => {
(<any>ext).extensionLocation = URI.revive(rpcProtocol.transformIncomingURIs(ext.extensionLocation));
(<Mutable<IRelaxedExtensionDescription>>ext).extensionLocation = URI.revive(rpcProtocol.transformIncomingURIs(ext.extensionLocation));
const browserNlsBundleUris: { [language: string]: URI } = {};
if (ext.browserNlsBundleUris) {
Object.keys(ext.browserNlsBundleUris).forEach(lang => browserNlsBundleUris[lang] = URI.revive(rpcProtocol.transformIncomingURIs(ext.browserNlsBundleUris![lang])));
(<any>ext).browserNlsBundleUris = browserNlsBundleUris;
(<Mutable<IRelaxedExtensionDescription>>ext).browserNlsBundleUris = browserNlsBundleUris;
}
});
initData.environment.appRoot = URI.revive(rpcProtocol.transformIncomingURIs(initData.environment.appRoot));

View File

@@ -38,6 +38,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ResourceEdit } from 'vs/editor/browser/services/bulkEditService';
import { ButtonBar } from 'vs/base/browser/ui/button/button';
import { defaultButtonStyles } from 'vs/platform/theme/browser/defaultStyles';
import { Mutable } from 'vs/base/common/types';
const enum State {
Data = 'data',
@@ -314,9 +315,6 @@ export class BulkEditPane extends ViewPane {
}
private async _openElementAsEditor(e: IOpenEvent<BulkEditElement | undefined>): Promise<void> {
type Mutable<T> = {
-readonly [P in keyof T]: T[P]
};
const options: Mutable<ITextEditorOptions> = { ...e.editorOptions };
let fileElement: FileElement;

View File

@@ -698,7 +698,7 @@ export class CommentController implements IEditorContribution {
return;
}
const matchedNewCommentThreadZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && (zoneWidget.commentThread as any).commentThreadHandle === -1 && Range.equalsRange(zoneWidget.commentThread.range, thread.range));
const matchedNewCommentThreadZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.commentThreadHandle === -1 && Range.equalsRange(zoneWidget.commentThread.range, thread.range));
if (matchedNewCommentThreadZones.length) {
matchedNewCommentThreadZones[0].update(thread);

View File

@@ -12,6 +12,7 @@ import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEn
import { IDiagnosticInfoOptions, IDiagnosticInfo } from 'vs/platform/diagnostics/common/diagnostics';
import { ITelemetryData, TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
import { IExtensionHostExitInfo } from 'vs/workbench/services/remote/common/remoteAgentService';
import { Mutable } from 'vs/base/common/types';
export interface IGetEnvironmentDataArguments {
remoteAuthority: string;
@@ -118,7 +119,7 @@ export class RemoteExtensionEnvironmentChannelClient {
const extension = await channel.call<IExtensionDescription | null>('scanSingleExtension', args);
if (extension) {
(<any>extension).extensionLocation = URI.revive(extension.extensionLocation);
(<Mutable<IExtensionDescription>>extension).extensionLocation = URI.revive(extension.extensionLocation);
}
return extension;
}

View File

@@ -326,9 +326,9 @@ function _parse(content: string, filename: string | null, locationKeyName: strin
function escapeVal(str: string): string {
return str.replace(/&#([0-9]+);/g, function (_: string, m0: string) {
return (<any>String).fromCodePoint(parseInt(m0, 10));
return String.fromCodePoint(parseInt(m0, 10));
}).replace(/&#x([0-9a-f]+);/g, function (_: string, m0: string) {
return (<any>String).fromCodePoint(parseInt(m0, 16));
return String.fromCodePoint(parseInt(m0, 16));
}).replace(/&amp;|&lt;|&gt;|&quot;|&apos;/g, function (_: string) {
switch (_) {
case '&amp;': return '&';