提交 dff8887e 编写于 作者: M Matt Bierner

Fix more noImplicitAny errors in vs code tests

上级 8c97c1d1
......@@ -86,11 +86,11 @@ suite('dom', () => {
//});
test('safeStringify', function () {
let obj1 = {
let obj1: any = {
friend: null
};
let obj2 = {
let obj2: any = {
friend: null
};
......@@ -100,7 +100,7 @@ suite('dom', () => {
let arr: any = [1];
arr.push(arr);
let circular = {
let circular: any = {
a: 42,
b: null,
c: [
......
......@@ -202,7 +202,7 @@ suite('Arrays', () => {
});
test('top', function () {
const cmp = (a, b) => {
const cmp = (a: number, b: number) => {
assert.strictEqual(typeof a, 'number', 'typeof a');
assert.strictEqual(typeof b, 'number', 'typeof b');
return a - b;
......@@ -218,7 +218,7 @@ suite('Arrays', () => {
});
test('topAsync', function (done) {
const cmp = (a, b) => {
const cmp = (a: number, b: number) => {
assert.strictEqual(typeof a, 'number', 'typeof a');
assert.strictEqual(typeof b, 'number', 'typeof b');
return a - b;
......
......@@ -23,7 +23,7 @@ suite('Assert', () => {
assert.throws(function () {
ok(null, 'Foo Bar');
}, function (e) {
}, function (e: Error) {
return e.message.indexOf('Foo Bar') >= 0;
});
......
......@@ -399,7 +399,7 @@ suite('Event utils', () => {
suite('buffer', () => {
test('should buffer events', () => {
const result = [];
const result: number[] = [];
const emitter = new Emitter<number>();
const event = emitter.event;
const bufferedEvent = buffer(event);
......@@ -421,7 +421,7 @@ suite('Event utils', () => {
});
test('should buffer events on next tick', () => {
const result = [];
const result: number[] = [];
const emitter = new Emitter<number>();
const event = emitter.event;
const bufferedEvent = buffer(event, true);
......@@ -445,7 +445,7 @@ suite('Event utils', () => {
});
test('should fire initial buffer events', () => {
const result = [];
const result: number[] = [];
const emitter = new Emitter<number>();
const event = emitter.event;
const bufferedEvent = buffer(event, false, [-2, -1, 0]);
......@@ -463,7 +463,7 @@ suite('Event utils', () => {
suite('echo', () => {
test('should echo events', () => {
const result = [];
const result: number[] = [];
const emitter = new Emitter<number>();
const event = emitter.event;
const echoEvent = echo(event);
......@@ -485,8 +485,8 @@ suite('Event utils', () => {
});
test('should echo events for every listener', () => {
const result1 = [];
const result2 = [];
const result1: number[] = [];
const result2: number[] = [];
const emitter = new Emitter<number>();
const event = emitter.event;
const echoEvent = echo(event);
......@@ -524,7 +524,7 @@ suite('Event utils', () => {
suite('EventMultiplexer', () => {
test('works', () => {
const result = [];
const result: number[] = [];
const m = new EventMultiplexer<number>();
m.event(r => result.push(r));
......@@ -538,7 +538,7 @@ suite('Event utils', () => {
});
test('multiplexer dispose works', () => {
const result = [];
const result: number[] = [];
const m = new EventMultiplexer<number>();
m.event(r => result.push(r));
......@@ -558,7 +558,7 @@ suite('Event utils', () => {
});
test('event dispose works', () => {
const result = [];
const result: number[] = [];
const m = new EventMultiplexer<number>();
m.event(r => result.push(r));
......@@ -578,7 +578,7 @@ suite('Event utils', () => {
});
test('mutliplexer event dispose works', () => {
const result = [];
const result: number[] = [];
const m = new EventMultiplexer<number>();
m.event(r => result.push(r));
......@@ -598,7 +598,7 @@ suite('Event utils', () => {
});
test('hot start works', () => {
const result = [];
const result: number[] = [];
const m = new EventMultiplexer<number>();
m.event(r => result.push(r));
......@@ -616,7 +616,7 @@ suite('Event utils', () => {
});
test('cold start works', () => {
const result = [];
const result: number[] = [];
const m = new EventMultiplexer<number>();
const e1 = new Emitter<number>();
......@@ -635,7 +635,7 @@ suite('Event utils', () => {
});
test('late add works', () => {
const result = [];
const result: number[] = [];
const m = new EventMultiplexer<number>();
const e1 = new Emitter<number>();
......@@ -656,7 +656,7 @@ suite('Event utils', () => {
});
test('add dispose works', () => {
const result = [];
const result: number[] = [];
const m = new EventMultiplexer<number>();
const e1 = new Emitter<number>();
......
......@@ -5,7 +5,7 @@
'use strict';
import * as assert from 'assert';
import { IFilter, or, matchesPrefix, matchesStrictPrefix, matchesCamelCase, matchesSubString, matchesContiguousSubString, matchesWords, fuzzyScore, nextTypoPermutation, fuzzyScoreGraceful } from 'vs/base/common/filters';
import { IFilter, or, matchesPrefix, matchesStrictPrefix, matchesCamelCase, matchesSubString, matchesContiguousSubString, matchesWords, fuzzyScore, nextTypoPermutation, fuzzyScoreGraceful, IMatch } from 'vs/base/common/filters';
function filterOk(filter: IFilter, word: string, wordToMatchAgainst: string, highlights?: { start: number; end: number; }[]) {
let r = filter(word, wordToMatchAgainst);
......@@ -15,15 +15,16 @@ function filterOk(filter: IFilter, word: string, wordToMatchAgainst: string, hig
}
}
function filterNotOk(filter, word, suggestion) {
function filterNotOk(filter: IFilter, word: string, suggestion: string) {
assert(!filter(word, suggestion));
}
suite('Filters', () => {
test('or', function () {
let filter, counters;
let newFilter = function (i, r) {
return function () { counters[i]++; return r; };
let filter: IFilter;
let counters: number[];
let newFilter = function (i: number, r: boolean): IFilter {
return function (): IMatch[] { counters[i]++; return r as any; };
};
counters = [0, 0];
......
......@@ -7,12 +7,12 @@
import * as assert from 'assert';
import objects = require('vs/base/common/objects');
let check = (one, other, msg) => {
let check = (one: any, other: any, msg: string) => {
assert(objects.equals(one, other), msg);
assert(objects.equals(other, one), '[reverse] ' + msg);
};
let checkNot = (one, other, msg) => {
let checkNot = (one: any, other: any, msg: string) => {
assert(!objects.equals(one, other), msg);
assert(!objects.equals(other, one), '[reverse] ' + msg);
};
......@@ -92,11 +92,11 @@ suite('Objects', () => {
});
test('safeStringify', function () {
let obj1 = {
let obj1: any = {
friend: null
};
let obj2 = {
let obj2: any = {
friend: null
};
......@@ -106,7 +106,7 @@ suite('Objects', () => {
let arr: any = [1];
arr.push(arr);
let circular = {
let circular: any = {
a: 42,
b: null,
c: [
......
......@@ -65,30 +65,30 @@ suite('Polyfill Promise', function () {
(<any[]>[Promise, PolyfillPromise]).forEach(PromiseCtor => {
test(PromiseCtor.name + ', resolved value', function () {
return new PromiseCtor(resolve => resolve(1)).then(value => assert.equal(value, 1));
return new PromiseCtor((resolve: Function) => resolve(1)).then((value: number) => assert.equal(value, 1));
});
test(PromiseCtor.name + ', rejected value', function () {
return new PromiseCtor((_, reject) => reject(1)).then(null, value => assert.equal(value, 1));
return new PromiseCtor((_: Function, reject: Function) => reject(1)).then(null, (value: number) => assert.equal(value, 1));
});
test(PromiseCtor.name + ', catch', function () {
return new PromiseCtor((_, reject) => reject(1)).catch(value => assert.equal(value, 1));
return new PromiseCtor((_: Function, reject: Function) => reject(1)).catch((value: number) => assert.equal(value, 1));
});
test(PromiseCtor.name + ', static-resolve', function () {
return PromiseCtor.resolve(42).then(value => assert.equal(value, 42));
return PromiseCtor.resolve(42).then((value: number) => assert.equal(value, 42));
});
test(PromiseCtor.name + ', static-reject', function () {
return PromiseCtor.reject(42).then(null, value => assert.equal(value, 42));
return PromiseCtor.reject(42).then(null, (value: number) => assert.equal(value, 42));
});
test(PromiseCtor.name + ', static-all, 1', function () {
return PromiseCtor.all([
PromiseCtor.resolve(1),
PromiseCtor.resolve(2)
]).then(values => {
]).then((values: number[]) => {
assert.deepEqual(values, [1, 2]);
});
});
......@@ -98,7 +98,7 @@ suite('Polyfill Promise', function () {
PromiseCtor.resolve(1),
3,
PromiseCtor.resolve(2)
]).then(values => {
]).then((values: number[]) => {
assert.deepEqual(values, [1, 3, 2]);
});
});
......@@ -108,7 +108,7 @@ suite('Polyfill Promise', function () {
PromiseCtor.resolve(1),
PromiseCtor.reject(13),
PromiseCtor.reject(12),
]).catch(values => {
]).catch((values: number) => {
assert.deepEqual(values, 13);
});
});
......@@ -117,7 +117,7 @@ suite('Polyfill Promise', function () {
return PromiseCtor.race([
PromiseCtor.resolve(1),
PromiseCtor.resolve(2),
]).then(value => {
]).then((value: number) => {
assert.deepEqual(value, 1);
});
});
......@@ -126,7 +126,7 @@ suite('Polyfill Promise', function () {
return PromiseCtor.race([
PromiseCtor.reject(-1),
PromiseCtor.resolve(2),
]).catch(value => {
]).catch((value: number) => {
assert.deepEqual(value, -1);
});
});
......@@ -135,7 +135,7 @@ suite('Polyfill Promise', function () {
return PromiseCtor.race([
PromiseCtor.resolve(1),
PromiseCtor.reject(2),
]).then(value => {
]).then((value: number) => {
assert.deepEqual(value, 1);
});
});
......@@ -143,7 +143,7 @@ suite('Polyfill Promise', function () {
test(PromiseCtor.name + ', throw in ctor', function () {
return new PromiseCtor(() => {
throw new Error('sooo bad');
}).catch(err => {
}).catch((err: Error) => {
assert.equal(err.message, 'sooo bad');
});
});
......
......@@ -13,15 +13,15 @@ const sequence = flow.sequence;
const parallel = flow.parallel;
suite('Flow', () => {
function assertCounterEquals(counter, expected): void {
function assertCounterEquals(counter: number, expected: number): void {
assert.ok(counter === expected, 'Expected ' + expected + ' assertions, but got ' + counter);
}
function syncThrowsError(callback): void {
function syncThrowsError(callback: any): void {
callback(new Error('foo'), null);
}
function syncSequenceGetThrowsError(value, callback) {
function syncSequenceGetThrowsError(value: any, callback: any) {
sequence(
function onError(error) {
callback(error, null);
......@@ -31,27 +31,27 @@ suite('Flow', () => {
syncThrowsError(this);
},
function handleFirst(first) {
function handleFirst(first: number) {
//Foo
}
);
}
function syncGet(value, callback): void {
function syncGet(value: any, callback: any): void {
callback(null, value);
}
function syncGetError(value, callback): void {
function syncGetError(value: any, callback: any): void {
callback(new Error(''), null);
}
function asyncGet(value, callback): void {
function asyncGet(value: any, callback: any): void {
process.nextTick(function () {
callback(null, value);
});
}
function asyncGetError(value, callback): void {
function asyncGetError(value: any, callback: any): void {
process.nextTick(function () {
callback(new Error(''), null);
});
......@@ -72,7 +72,7 @@ suite('Flow', () => {
});
test('loopByFunctionSync', function (done: () => void) {
const elements = function (callback) {
const elements = function (callback: Function) {
callback(null, ['1', '2', '3']);
};
......@@ -87,7 +87,7 @@ suite('Flow', () => {
});
test('loopByFunctionAsync', function (done: () => void) {
const elements = function (callback) {
const elements = function (callback: Function) {
process.nextTick(function () {
callback(null, ['1', '2', '3']);
});
......@@ -180,19 +180,19 @@ suite('Flow', () => {
syncGet('1', this);
},
function handleFirst(this: any, first) {
function handleFirst(this: any, first: number) {
assert.deepEqual('1', first);
assertionCount++;
syncGet('2', this);
},
function handleSecond(this: any, second) {
function handleSecond(this: any, second: any) {
assert.deepEqual('2', second);
assertionCount++;
syncGet(null, this);
},
function handleThird(third) {
function handleThird(third: any) {
assert.ok(!third);
assertionCount++;
......@@ -216,19 +216,19 @@ suite('Flow', () => {
asyncGet('1', this);
},
function handleFirst(this: any, first) {
function handleFirst(this: any, first: number) {
assert.deepEqual('1', first);
assertionCount++;
asyncGet('2', this);
},
function handleSecond(this: any, second) {
function handleSecond(this: any, second: number) {
assert.deepEqual('2', second);
assertionCount++;
asyncGet(null, this);
},
function handleThird(third) {
function handleThird(third: number) {
assert.ok(!third);
assertionCount++;
......@@ -256,13 +256,13 @@ suite('Flow', () => {
syncGet('1', this);
},
function handleFirst(this: any, first) {
function handleFirst(this: any, first: number) {
assert.deepEqual('1', first);
assertionCount++;
syncGet('2', this);
},
function handleSecond(second) {
function handleSecond(second: number) {
if (true) {
throw new Error('');
}
......@@ -270,7 +270,7 @@ suite('Flow', () => {
// syncGet(null, this);
},
function handleThird(third) {
function handleThird(third: number) {
throw new Error('We should not be here');
}
);
......@@ -293,13 +293,13 @@ suite('Flow', () => {
syncGet('1', this);
},
function handleFirst(this: any, first) {
function handleFirst(this: any, first: number) {
assert.deepEqual('1', first);
assertionCount++;
syncGetError('2', this);
},
function handleSecond(second) {
function handleSecond(second: number) {
throw new Error('We should not be here');
}
);
......@@ -322,13 +322,13 @@ suite('Flow', () => {
asyncGet('1', this);
},
function handleFirst(this: any, first) {
function handleFirst(this: any, first: number) {
assert.deepEqual('1', first);
assertionCount++;
asyncGet('2', this);
},
function handleSecond(second) {
function handleSecond(second: number) {
if (true) {
throw new Error('');
}
......@@ -336,7 +336,7 @@ suite('Flow', () => {
// asyncGet(null, this);
},
function handleThird(third) {
function handleThird(third: number) {
throw new Error('We should not be here');
}
);
......@@ -359,13 +359,13 @@ suite('Flow', () => {
asyncGet('1', this);
},
function handleFirst(this: any, first) {
function handleFirst(this: any, first: number) {
assert.deepEqual('1', first);
assertionCount++;
asyncGetError('2', this);
},
function handleSecond(second) {
function handleSecond(second: number) {
throw new Error('We should not be here');
}
);
......@@ -396,12 +396,12 @@ suite('Flow', () => {
this(true);
},
function getSecond(this: any, result) {
function getSecond(this: any, result: boolean) {
assert.equal(result, true);
this(false);
},
function last(result) {
function last(result: boolean) {
assert.equal(result, false);
assertionCount++;
......
......@@ -13,8 +13,8 @@ import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
suite('Workbench Memento', () => {
let context;
let storage;
let context: Scope = undefined;
let storage: StorageService;
setup(() => {
storage = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id);
......@@ -70,9 +70,9 @@ suite('Workbench Memento', () => {
assert.deepEqual(memento, {});
// Assert the Mementos are also removed from storage
assert.strictEqual(storage.get('memento/memento.test', Scope.GLOBAL, null), null);
assert.strictEqual(storage.get('memento/memento.test', StorageScope.GLOBAL, null), null);
assert.strictEqual(storage.get('memento/memento.test', Scope.WORKSPACE, null), null);
assert.strictEqual(storage.get('memento/memento.test', StorageScope.WORKSPACE, null), null);
});
test('Save and Load', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册