提交 6801e4c6 编写于 作者: B Benjamin Pasero

debt - less explicit any

上级 89b4f048
......@@ -247,7 +247,7 @@ export class Gesture extends Disposable {
}
private newGestureEvent(type: string, initialTarget?: EventTarget): GestureEvent {
let event = <GestureEvent>(<any>document.createEvent('CustomEvent'));
let event = document.createEvent('CustomEvent') as unknown as GestureEvent;
event.initEvent(type, false, true);
event.initialTarget = initialTarget;
event.tapCount = 0;
......
......@@ -271,7 +271,7 @@ export class DropdownMenu extends BaseDropdown {
}
export class DropdownMenuActionViewItem extends BaseActionViewItem {
private menuActionsOrProvider: any;
private menuActionsOrProvider: ReadonlyArray<IAction> | IActionProvider;
private dropdownMenu: DropdownMenu | undefined;
private contextMenuProvider: IContextMenuProvider;
private actionViewItemProvider?: IActionViewItemProvider;
......@@ -317,7 +317,7 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem {
if (Array.isArray(this.menuActionsOrProvider)) {
options.actions = this.menuActionsOrProvider;
} else {
options.actionProvider = this.menuActionsOrProvider;
options.actionProvider = this.menuActionsOrProvider as IActionProvider;
}
this.dropdownMenu = this._register(new DropdownMenu(container, options));
......@@ -341,7 +341,7 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem {
}
}
setActionContext(newContext: any): void {
setActionContext(newContext: unknown): void {
super.setActionContext(newContext);
if (this.dropdownMenu) {
......
......@@ -6,7 +6,7 @@
import 'vs/css!./menu';
import * as nls from 'vs/nls';
import * as strings from 'vs/base/common/strings';
import { IActionRunner, IAction, Action, IActionViewItem } from 'vs/base/common/actions';
import { IActionRunner, IAction, Action } from 'vs/base/common/actions';
import { ActionBar, IActionViewItemProvider, ActionsOrientation, Separator, ActionViewItem, IActionViewItemOptions, BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { ResolvedKeybinding, KeyCode } from 'vs/base/common/keyCodes';
import { addClass, EventType, EventHelper, EventLike, removeTabIndexAndUpdateFocus, isAncestor, hasClass, addDisposableListener, removeClass, append, $, addClasses, removeClasses, clearNode } from 'vs/base/browser/dom';
......@@ -205,7 +205,7 @@ export class Menu extends ActionBar {
container.appendChild(this.scrollableElement.getDomNode());
this.scrollableElement.scanDomNode();
this.viewItems.filter(item => !(item instanceof MenuSeparatorActionViewItem)).forEach((item: IActionViewItem, index: number, array: any[]) => {
this.viewItems.filter(item => !(item instanceof MenuSeparatorActionViewItem)).forEach((item, index, array) => {
(item as BaseMenuActionViewItem).updatePositionInSet(index + 1, array.length);
});
}
......@@ -363,7 +363,7 @@ class BaseMenuActionViewItem extends BaseActionViewItem {
private cssClass: string;
protected menuStyle: IMenuStyles | undefined;
constructor(ctx: any, action: IAction, options: IMenuItemOptions = {}) {
constructor(ctx: unknown, action: IAction, options: IMenuItemOptions = {}) {
options.isMenu = true;
super(action, action, options);
......
......@@ -31,7 +31,7 @@ const shortcutEvent: Event<any> = Object.freeze(function (callback, context?): I
export namespace CancellationToken {
export function isCancellationToken(thing: any): thing is CancellationToken {
export function isCancellationToken(thing: unknown): thing is CancellationToken {
if (thing === CancellationToken.None || thing === CancellationToken.Cancelled) {
return true;
}
......
......@@ -13,7 +13,7 @@ export interface IErrorWithActions {
actions?: ReadonlyArray<IAction>;
}
export function isErrorWithActions(obj: any): obj is IErrorWithActions {
export function isErrorWithActions(obj: unknown): obj is IErrorWithActions {
return obj instanceof Error && Array.isArray((obj as IErrorWithActions).actions);
}
......
......@@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export function once<T extends Function>(this: any, fn: T): T {
export function once<T extends Function>(this: unknown, fn: T): T {
const _this = this;
let didCall = false;
let result: any;
let result: unknown;
return function () {
if (didCall) {
......@@ -17,5 +17,5 @@ export function once<T extends Function>(this: any, fn: T): T {
result = fn.apply(_this, arguments);
return result;
} as any as T;
}
\ No newline at end of file
} as unknown as T;
}
......@@ -21,7 +21,7 @@ export class Lazy<T> {
private _didRun: boolean = false;
private _value?: T;
private _error: any;
private _error: Error | undefined;
constructor(
private readonly executor: () => T,
......
......@@ -49,8 +49,7 @@ export interface IDisposable {
}
export function isDisposable<E extends object>(thing: E): thing is E & IDisposable {
return typeof (<IDisposable><any>thing).dispose === 'function'
&& (<IDisposable><any>thing).dispose.length === 0;
return typeof (<IDisposable>thing).dispose === 'function' && (<IDisposable>thing).dispose.length === 0;
}
export function dispose<T extends IDisposable>(disposable: T): T;
......@@ -124,7 +123,7 @@ export class DisposableStore implements IDisposable {
if (!t) {
return t;
}
if ((t as any as DisposableStore) === this) {
if ((t as unknown as DisposableStore) === this) {
throw new Error('Cannot register a disposable on itself!');
}
......@@ -158,7 +157,7 @@ export abstract class Disposable implements IDisposable {
}
protected _register<T extends IDisposable>(t: T): T {
if ((t as any as Disposable) === this) {
if ((t as unknown as Disposable) === this) {
throw new Error('Cannot register a disposable on itself!');
}
return this._store.add(t);
......
......@@ -11,7 +11,7 @@ import { LRUCache } from 'vs/base/common/map';
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize}
*/
export const canNormalize = typeof ((<any>'').normalize) === 'function';
export const canNormalize = typeof (String.prototype as any /* standalone editor compilation */).normalize === 'function';
const nfcCache = new LRUCache<string, string>(10000); // bounded to 10000 elements
export function normalizeNFC(str: string): string {
......
......@@ -5,6 +5,7 @@
import { CharCode } from 'vs/base/common/charCode';
import { Constants } from 'vs/base/common/uint';
import { canNormalize, normalizeNFD } from 'vs/base/common/normalization';
export function isFalsyOrWhitespace(str: string | undefined): boolean {
if (!str || typeof str !== 'string') {
......@@ -853,15 +854,15 @@ export function removeAnsiEscapeCodes(str: string): string {
}
export const removeAccents: (str: string) => string = (function () {
if (typeof (String.prototype as any /* standalone editor compilation */).normalize !== 'function') {
// ☹️ no ES6 features...
if (!canNormalize) {
// no ES6 features...
return function (str: string) { return str; };
} else {
// transform into NFD form and remove accents
// see: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/37511463#37511463
const regex = /[\u0300-\u036f]/g;
return function (str: string) {
return (str as any /* standalone editor compilation */).normalize('NFD').replace(regex, '');
return normalizeNFD(str).replace(regex, '');
};
}
})();
......
......@@ -6036,7 +6036,7 @@ declare namespace monaco.languages {
}
/**
* A provider of colors for editor models.
* A provider of folding ranges for editor models.
*/
export interface FoldingRangeProvider {
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册