Skip to content

Commit bef497f

Browse files
author
Benjamin Pasero
committed
avoid more implicit any and some 💄
1 parent 7712905 commit bef497f

114 files changed

Lines changed: 282 additions & 296 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/vs/base/browser/htmlContentRenderer.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class StringStream {
186186
}
187187

188188
public next(): string {
189-
var next = this.peek();
189+
const next = this.peek();
190190
this.advance();
191191
return next;
192192
}
@@ -219,7 +219,7 @@ interface IFormatParseTree {
219219
}
220220

221221
function _renderFormattedText(element: Node, treeNode: IFormatParseTree, actionCallback?: (content: string, event?: IMouseEvent) => void) {
222-
var child: Node;
222+
let child: Node;
223223

224224
if (treeNode.type === FormatType.Text) {
225225
child = document.createTextNode(treeNode.content);
@@ -231,7 +231,7 @@ function _renderFormattedText(element: Node, treeNode: IFormatParseTree, actionC
231231
child = document.createElement('i');
232232
}
233233
else if (treeNode.type === FormatType.Action) {
234-
var a = document.createElement('a');
234+
const a = document.createElement('a');
235235
a.href = '#';
236236
DOM.addStandardDisposableListener(a, 'click', (event) => {
237237
actionCallback(String(treeNode.index), event);
@@ -259,20 +259,20 @@ function _renderFormattedText(element: Node, treeNode: IFormatParseTree, actionC
259259

260260
function parseFormattedText(content: string): IFormatParseTree {
261261

262-
var root: IFormatParseTree = {
262+
const root: IFormatParseTree = {
263263
type: FormatType.Root,
264264
children: []
265265
};
266266

267-
var actionItemIndex = 0;
268-
var current = root;
269-
var stack: IFormatParseTree[] = [];
270-
var stream = new StringStream(content);
267+
let actionItemIndex = 0;
268+
let current = root;
269+
const stack: IFormatParseTree[] = [];
270+
const stream = new StringStream(content);
271271

272272
while (!stream.eos()) {
273-
var next = stream.next();
273+
let next = stream.next();
274274

275-
var isEscapedFormatType = (next === '\\' && formatTagType(stream.peek()) !== FormatType.Invalid);
275+
const isEscapedFormatType = (next === '\\' && formatTagType(stream.peek()) !== FormatType.Invalid);
276276
if (isEscapedFormatType) {
277277
next = stream.next(); // unread the backslash if it escapes a format tag type
278278
}
@@ -284,11 +284,11 @@ function parseFormattedText(content: string): IFormatParseTree {
284284
current = stack.pop();
285285
}
286286

287-
var type = formatTagType(next);
287+
const type = formatTagType(next);
288288
if (current.type === type || (current.type === FormatType.Action && type === FormatType.ActionClose)) {
289289
current = stack.pop();
290290
} else {
291-
var newCurrent: IFormatParseTree = {
291+
const newCurrent: IFormatParseTree = {
292292
type: type,
293293
children: []
294294
};
@@ -313,7 +313,7 @@ function parseFormattedText(content: string): IFormatParseTree {
313313

314314
} else {
315315
if (current.type !== FormatType.Text) {
316-
var textCurrent: IFormatParseTree = {
316+
const textCurrent: IFormatParseTree = {
317317
type: FormatType.Text,
318318
content: next
319319
};

src/vs/base/browser/ui/resourceviewer/resourceViewer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class ResourceViewer {
115115
descriptor: IResourceDescriptor,
116116
container: Builder,
117117
scrollbar: DomScrollableElement,
118-
openExternal: (URI) => void,
118+
openExternal: (uri: URI) => void,
119119
metadataClb?: (meta: string) => void
120120
): void {
121121
// Ensure CSS class

src/vs/base/common/cancellation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'use strict';
77

88
import Event, { Emitter } from 'vs/base/common/event';
9+
import { IDisposable } from 'vs/base/common/lifecycle';
910

1011
export interface CancellationToken {
1112
readonly isCancellationRequested: boolean;
@@ -16,10 +17,10 @@ export interface CancellationToken {
1617
readonly onCancellationRequested: Event<any>;
1718
}
1819

19-
const shortcutEvent: Event<any> = Object.freeze(function (callback, context?) {
20+
const shortcutEvent = Object.freeze(function (callback, context?): IDisposable {
2021
let handle = setTimeout(callback.bind(context), 0);
2122
return { dispose() { clearTimeout(handle); } };
22-
});
23+
} as Event<any>);
2324

2425
export namespace CancellationToken {
2526

src/vs/base/common/collections.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
2929
*/
3030
export function values<T>(from: IStringDictionary<T> | INumberDictionary<T>): T[] {
3131
const result: T[] = [];
32-
for (var key in from) {
32+
for (let key in from) {
3333
if (hasOwnProperty.call(from, key)) {
3434
result.push(from[key]);
3535
}
@@ -39,7 +39,7 @@ export function values<T>(from: IStringDictionary<T> | INumberDictionary<T>): T[
3939

4040
export function size<T>(from: IStringDictionary<T> | INumberDictionary<T>): number {
4141
let count = 0;
42-
for (var key in from) {
42+
for (let key in from) {
4343
if (hasOwnProperty.call(from, key)) {
4444
count += 1;
4545
}

src/vs/base/common/comparers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export function noIntlCompareFileNames(one: string, other: string): number {
5959

6060
export function compareFileExtensions(one: string, other: string): number {
6161
if (intlFileNameCollator) {
62-
const oneMatch = one ? FileNameMatch.exec(one) : [];
63-
const otherMatch = other ? FileNameMatch.exec(other) : [];
62+
const oneMatch = one ? FileNameMatch.exec(one) : [] as RegExpExecArray;
63+
const otherMatch = other ? FileNameMatch.exec(other) : [] as RegExpExecArray;
6464

6565
const oneName = oneMatch[1] || '';
6666
const oneExtension = oneMatch[3] || '';
@@ -92,8 +92,8 @@ export function compareFileExtensions(one: string, other: string): number {
9292
}
9393

9494
function noIntlCompareFileExtensions(one: string, other: string): number {
95-
const oneMatch = one ? FileNameMatch.exec(one.toLowerCase()) : [];
96-
const otherMatch = other ? FileNameMatch.exec(other.toLowerCase()) : [];
95+
const oneMatch = one ? FileNameMatch.exec(one.toLowerCase()) : [] as RegExpExecArray;
96+
const otherMatch = other ? FileNameMatch.exec(other.toLowerCase()) : [] as RegExpExecArray;
9797

9898
const oneName = oneMatch[1] || '';
9999
const oneExtension = oneMatch[3] || '';

src/vs/base/common/diagnostics.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import * as Platform from 'vs/base/common/platform';
1111
* Then trigger an action that will write to diagnostics to see all cached output from the past.
1212
*/
1313

14-
var globals = Platform.globals;
14+
const globals = Platform.globals;
1515
if (!globals.Monaco) {
1616
globals.Monaco = {};
1717
}
1818
globals.Monaco.Diagnostics = {};
1919

20-
var switches = globals.Monaco.Diagnostics;
21-
var map = new Map<string, Function[]>();
22-
var data: any[] = [];
20+
const switches = globals.Monaco.Diagnostics;
21+
const map = new Map<string, Function[]>();
22+
const data: any[] = [];
2323

2424
function fifo(array: any[], size: number) {
2525
while (array.length > size) {
@@ -37,29 +37,29 @@ export function register(what: string, fn: Function): (...args: any[]) => void {
3737
}
3838

3939
// register switch
40-
var flag = switches[what] || false;
40+
const flag = switches[what] || false;
4141
switches[what] = flag;
4242

4343
// register function
44-
var tracers = map.get(what) || [];
44+
const tracers = map.get(what) || [];
4545
tracers.push(fn);
4646
map.set(what, tracers);
4747

48-
var result = function (...args: any[]) {
48+
const result = function (...args: any[]) {
4949

50-
var idx: number;
50+
let idx: number;
5151

5252
if (switches[what] === true) {
5353
// replay back-in-time functions
54-
var allArgs = [arguments];
54+
const allArgs = [arguments];
5555
idx = data.indexOf(fn);
5656
if (idx !== -1) {
5757
allArgs.unshift.apply(allArgs, data[idx + 1] || []);
5858
data[idx + 1] = [];
5959
}
6060

61-
var doIt: () => void = function () {
62-
var thisArguments = allArgs.shift();
61+
const doIt: () => void = function () {
62+
const thisArguments = allArgs.shift();
6363
fn.apply(fn, thisArguments);
6464
if (allArgs.length > 0) {
6565
Platform.setTimeout(doIt, 500);
@@ -71,10 +71,10 @@ export function register(what: string, fn: Function): (...args: any[]) => void {
7171
// know where to store
7272
idx = data.indexOf(fn);
7373
idx = idx !== -1 ? idx : data.length;
74-
var dataIdx = idx + 1;
74+
const dataIdx = idx + 1;
7575

7676
// store arguments
77-
var allargs = data[dataIdx] || [];
77+
const allargs = data[dataIdx] || [];
7878
allargs.push(arguments);
7979
fifo(allargs, 50);
8080

src/vs/base/common/diff/diff2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { DiffChange } from 'vs/base/common/diff/diffChange';
99
export interface ISequence {
1010
getLength(): number;
1111
getElementHash(index: number): string;
12+
[index: number]: string;
1213
}
1314

1415
export interface IDiffChange {

src/vs/base/common/event.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class ChainableEvent<T> implements IChainableEvent<T> {
424424
return new ChainableEvent(filterEvent(this._event, fn));
425425
}
426426

427-
on(listener, thisArgs, disposables: IDisposable[]) {
427+
on(listener: (e: T) => any, thisArgs: any, disposables: IDisposable[]) {
428428
return this._event(listener, thisArgs, disposables);
429429
}
430430
}
@@ -514,10 +514,10 @@ export function echo<T>(event: Event<T>, nextTick = false, buffer: T[] = []): Ev
514514
emitter.fire(e);
515515
});
516516

517-
const flush = (listener, thisArgs?) => buffer.forEach(e => listener.call(thisArgs, e));
517+
const flush = (listener: (e: T) => any, thisArgs?: any) => buffer.forEach(e => listener.call(thisArgs, e));
518518

519519
const emitter = new Emitter<T>({
520-
onListenerDidAdd(emitter, listener, thisArgs?) {
520+
onListenerDidAdd(emitter, listener: (e: T) => any, thisArgs?: any) {
521521
if (nextTick) {
522522
setTimeout(() => flush(listener, thisArgs));
523523
} else {

src/vs/base/common/graph.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class Graph<T> {
3030
}
3131

3232
roots(): Node<T>[] {
33-
var ret: Node<T>[] = [];
33+
const ret: Node<T>[] = [];
3434
forEach(this._nodes, entry => {
3535
if (isEmptyObject(entry.value.outgoing)) {
3636
ret.push(entry.value);
@@ -40,34 +40,34 @@ export class Graph<T> {
4040
}
4141

4242
traverse(start: T, inwards: boolean, callback: (data: T) => void): void {
43-
var startNode = this.lookup(start);
43+
const startNode = this.lookup(start);
4444
if (!startNode) {
4545
return;
4646
}
4747
this._traverse(startNode, inwards, Object.create(null), callback);
4848
}
4949

5050
private _traverse(node: Node<T>, inwards: boolean, seen: { [key: string]: boolean }, callback: (data: T) => void): void {
51-
var key = this._hashFn(node.data);
51+
const key = this._hashFn(node.data);
5252
if (seen[key]) {
5353
return;
5454
}
5555
seen[key] = true;
5656
callback(node.data);
57-
var nodes = inwards ? node.outgoing : node.incoming;
57+
const nodes = inwards ? node.outgoing : node.incoming;
5858
forEach(nodes, (entry) => this._traverse(entry.value, inwards, seen, callback));
5959
}
6060

6161
insertEdge(from: T, to: T): void {
62-
var fromNode = this.lookupOrInsertNode(from),
62+
const fromNode = this.lookupOrInsertNode(from),
6363
toNode = this.lookupOrInsertNode(to);
6464

6565
fromNode.outgoing[this._hashFn(to)] = toNode;
6666
toNode.incoming[this._hashFn(from)] = fromNode;
6767
}
6868

6969
removeNode(data: T): void {
70-
var key = this._hashFn(data);
70+
const key = this._hashFn(data);
7171
delete this._nodes[key];
7272
forEach(this._nodes, (entry) => {
7373
delete entry.value.outgoing[key];

src/vs/base/common/json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ export function parse(text: string, errors: ParseError[] = [], options?: ParseOp
837837
currentParent = previousParents.pop();
838838
},
839839
onArrayBegin: () => {
840-
let array = [];
840+
let array: any[] = [];
841841
onValue(array);
842842
previousParents.push(currentParent);
843843
currentParent = array;

0 commit comments

Comments
 (0)