提交 8639e21b 编写于 作者: M Matt Bierner

Remove some unneeded <any> casts

上级 bc347c43
......@@ -15,7 +15,7 @@ export function clone<T>(obj: T): T {
// See https://github.com/Microsoft/TypeScript/issues/10990
return obj as any;
}
const result = (Array.isArray(obj)) ? <any>[] : <any>{};
const result: any = Array.isArray(obj) ? [] : {};
Object.keys(obj).forEach((key: keyof T) => {
if (obj[key] && typeof obj[key] === 'object') {
result[key] = clone(obj[key]);
......@@ -30,7 +30,7 @@ export function deepClone<T>(obj: T): T {
if (!obj || typeof obj !== 'object') {
return obj;
}
const result = (Array.isArray(obj)) ? <any>[] : <any>{};
const result: any = Array.isArray(obj) ? [] : {};
Object.getOwnPropertyNames(obj).forEach((key: keyof T) => {
if (obj[key] && typeof obj[key] === 'object') {
result[key] = deepClone(obj[key]);
......@@ -231,7 +231,7 @@ export function derive(baseClass: any, derivedClass: any): void {
}
// Cast to any due to Bug 16188:PropertyDescriptor set and get function should be optional.
Object.defineProperty(derivedClass.prototype, 'constructor', <any>{ value: derivedClass, writable: true, configurable: true, enumerable: true });
Object.defineProperty(derivedClass.prototype, 'constructor', { value: derivedClass, writable: true, configurable: true, enumerable: true });
}
/**
......
......@@ -416,7 +416,7 @@ suite('Glob', () => {
assert.strictEqual(glob.match(expression, 'test.js', () => siblings), null);
expression = <any>{
expression = {
'**/*.js': {
}
};
......
......@@ -84,7 +84,7 @@ class MonacoWebWorkerImpl<T> extends EditorWorkerClient implements MonacoWebWork
};
};
let foreignProxy = <T><any>{};
let foreignProxy = {} as T;
for (let i = 0; i < foreignMethods.length; i++) {
foreignProxy[foreignMethods[i]] = createProxyMethod(foreignMethods[i], proxyMethodRequest);
}
......
......@@ -71,11 +71,11 @@ function fromRange(rng: Range): number[] {
suite('FindController', () => {
let queryState: { [key: string]: any; } = {};
let serviceCollection = new ServiceCollection();
serviceCollection.set(IStorageService, <any>{
serviceCollection.set(IStorageService, {
get: (key: string) => queryState[key],
getBoolean: (key: string) => !!queryState[key],
store: (key: string, value: any) => { queryState[key] = value; }
});
} as IStorageService);
test('issue #1857: F3, Find Next, acts like "Find Under Cursor"', () => {
withMockCodeEditor([
......@@ -392,11 +392,11 @@ suite('FindController query options persistence', () => {
queryState['editor.matchCase'] = false;
queryState['editor.wholeWord'] = false;
let serviceCollection = new ServiceCollection();
serviceCollection.set(IStorageService, <any>{
serviceCollection.set(IStorageService, {
get: (key: string) => queryState[key],
getBoolean: (key: string) => !!queryState[key],
store: (key: string, value: any) => { queryState[key] = value; }
});
} as IStorageService);
test('matchCase', () => {
withMockCodeEditor([
......
......@@ -11,7 +11,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { editorAction, ServicesAccessor, EditorAction, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
import { editorAction, ServicesAccessor, EditorAction, commonEditorContribution, IActionOptions } from 'vs/editor/common/editorCommonExtensions';
import { OnTypeFormattingEditProviderRegistry, DocumentRangeFormattingEditProviderRegistry } from 'vs/editor/common/modes';
import { getOnTypeFormattingEdits, getDocumentFormattingEdits, getDocumentRangeFormattingEdits, NoProviderError } from '../common/format';
import { EditOperationsCommand } from '../common/formatCommand';
......@@ -366,7 +366,7 @@ CommandsRegistry.registerCommand('editor.action.format', accessor => {
if (editor) {
return new class extends AbstractFormatAction {
constructor() {
super(<any>{});
super({} as IActionOptions);
}
_getFormattingEdits(editor: editorCommon.ICommonCodeEditor): TPromise<editorCommon.ISingleEditOperation[]> {
const model = editor.getModel();
......
......@@ -53,11 +53,11 @@ function fromRange(rng: Range): number[] {
suite('Multicursor selection', () => {
let queryState: { [key: string]: any; } = {};
let serviceCollection = new ServiceCollection();
serviceCollection.set(IStorageService, <any>{
serviceCollection.set(IStorageService, {
get: (key: string) => queryState[key],
getBoolean: (key: string) => !!queryState[key],
store: (key: string, value: any) => { queryState[key] = value; }
});
} as IStorageService);
test('issue #8817: Cursor position changes when you cancel multicursor', () => {
withMockCodeEditor([
......
......@@ -91,13 +91,13 @@ suite('Editor Core - Editor State', () => {
function createEditor({ model, position, selection, scroll }: IStubEditorState = {}): ICommonCodeEditor {
let mappedModel = model ? { uri: model.uri ? model.uri : URI.parse('http://dummy.org'), getVersionId: () => model.version } : null;
return <any>{
return {
getModel: (): IModel => <any>mappedModel,
getPosition: (): Position => position,
getSelection: (): Selection => selection,
getScrollLeft: (): number => scroll && scroll.left,
getScrollTop: (): number => scroll && scroll.top
};
} as ICommonCodeEditor;
}
});
......
......@@ -257,7 +257,7 @@ export class SearchViewlet extends Viewlet {
this.createSearchResultsView(builder);
this.actionRegistry = <any>{};
this.actionRegistry = {};
let actions: Action[] = [new CollapseDeepestExpandedLevelAction(this), new RefreshAction(this), new ClearSearchResultsAction(this)];
actions.forEach((action) => {
this.actionRegistry[action.id] = action;
......
......@@ -45,9 +45,9 @@ suite('Workbench - TerminalInstance', () => {
executable: '/bin/foosh',
args: ['-bar', 'baz']
};
const parentEnv1: IStringDictionary<string> = <any>{
const parentEnv1: IStringDictionary<string> = {
ok: true
};
} as any;
const env1 = TerminalInstance.createTerminalEnv(parentEnv1, shell1, '/foo', 'en-au');
assert.ok(env1['ok'], 'Parent environment is copied');
assert.deepStrictEqual(parentEnv1, { ok: true }, 'Parent environment is unchanged');
......@@ -63,7 +63,7 @@ suite('Workbench - TerminalInstance', () => {
executable: '/bin/foosh',
args: []
};
const parentEnv2: IStringDictionary<string> = <any>{
const parentEnv2: IStringDictionary<string> = {
LANG: 'en_US.UTF-8'
};
const env2 = TerminalInstance.createTerminalEnv(parentEnv2, shell2, '/foo', 'en-au');
......
......@@ -18,7 +18,7 @@ suite('Workbench - GettingStarted', () => {
suiteSetup(() => {
instantiation = new TestInstantiationService();
instantiation.stub(IWorkspaceContextService, <any>{
instantiation.stub(IWorkspaceContextService, {
getConfiguration: () => {
return {
env: {
......@@ -28,7 +28,7 @@ suite('Workbench - GettingStarted', () => {
};
}
});
instantiation.stub(IStorageService, <any>{
instantiation.stub(IStorageService, {
get: () => hideWelcomeSettingsValue,
store: (value) => hideWelcomeSettingsValue = value
});
......
......@@ -17,7 +17,7 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { Emitter } from 'vs/base/common/event';
let activeViewlet: Viewlet = <any>{};
let activeViewlet: Viewlet = {};
class TestViewletService implements IViewletService {
public _serviceBrand: any;
......
......@@ -21,11 +21,11 @@ suite('ExtHostMessageService', function () {
setImmediate(() => m.actions[0].run());
return () => { };
}
} as IMessageService, <any>{
choose() {
} as IMessageService, {
choose(severity, message, options, modal) {
throw new Error('not implemented');
}
});
} as IChoiceService);
return service.$showMessage(1, 'h', {}, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]).then(handle => {
assert.equal(handle, 42);
......@@ -39,11 +39,11 @@ suite('ExtHostMessageService', function () {
show(sev: number, m: { actions: Action[] }) {
actions = m.actions;
}
} as IMessageService, <any>{
choose() {
} as IMessageService, {
choose(severity, message, options, modal) {
throw new Error('not implemented');
}
});
} as IChoiceService);
// default close action
service.$showMessage(1, '', {}, [{ title: 'a thing', isCloseAffordance: false, handle: 0 }]);
......@@ -71,11 +71,11 @@ suite('ExtHostMessageService', function () {
c += 1;
};
}
} as IMessageService, <any>{
choose() {
} as IMessageService, {
choose(severity, message, options, modal) {
throw new Error('not implemented');
}
});
} as IChoiceService);
service.$showMessage(1, '', {}, [{ title: 'a thing', isCloseAffordance: true, handle: 0 }]);
assert.equal(actions.length, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册