mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Fixed --noImplicitAny test compiler issues
This commit is contained in:
+57
-49
@@ -1,6 +1,6 @@
|
||||
/// <reference path="lodash.d.ts" />
|
||||
|
||||
declare var $, jQuery;
|
||||
declare var $: any, jQuery: any;
|
||||
|
||||
interface IFoodOrganic {
|
||||
name: string;
|
||||
@@ -72,13 +72,13 @@ var keys: IKey[] = [
|
||||
{ 'dir': 'right', 'code': 100 }
|
||||
];
|
||||
|
||||
function Dog(name) {
|
||||
this.name = name;
|
||||
}
|
||||
class Dog {
|
||||
constructor(public name: string) {}
|
||||
|
||||
Dog.prototype.bark = function() {
|
||||
console.log('Woof, woof!');
|
||||
};
|
||||
public bark() {
|
||||
console.log('Woof, woof!');
|
||||
}
|
||||
}
|
||||
|
||||
var result : any;
|
||||
|
||||
@@ -166,7 +166,7 @@ result = <number>_.findIndex(['apple', 'banana', 'beet'], function(f) {
|
||||
result = <number>_.findIndex(['apple', 'banana', 'beet'], 'apple');
|
||||
result = <number>_.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'});
|
||||
|
||||
result = <number>_.findLastIndex(['apple', 'banana', 'beet'], function(f) {
|
||||
result = <number>_.findLastIndex(['apple', 'banana', 'beet'], function(f: string) {
|
||||
return /^b/.test(f);
|
||||
});
|
||||
result = <number>_.findLastIndex(['apple', 'banana', 'beet'], 'apple');
|
||||
@@ -240,7 +240,7 @@ result = <number[]>_.range(0, -10, -1);
|
||||
result = <number[]>_.range(1, 4, 0);
|
||||
result = <number[]>_.range(0);
|
||||
|
||||
result = <number[]>_.remove([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
||||
result = <number[]>_.remove([1, 2, 3, 4, 5, 6], function(num: number) { return num % 2 == 0; });
|
||||
result = <IFoodOrganic[]>_.remove(foodsOrganic, 'organic');
|
||||
result = <IFoodType[]>_.remove(foodsType, { 'type': 'vegetable'});
|
||||
|
||||
@@ -409,32 +409,32 @@ result = <IStoogesAge>_.min(stoogesAges, 'age');
|
||||
|
||||
result = <string[]>_.pluck(stoogesAges, 'name');
|
||||
|
||||
result = <any>_.reduce([1, 2, 3], function(sum, num) {
|
||||
result = <number>_.reduce<number, number>([1, 2, 3], function(sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
result = <any>_.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
|
||||
result[key] = num * 3;
|
||||
return result;
|
||||
result = <any>_.reduce<number, any>({ 'a': 1, 'b': 2, 'c': 3 }, function(r: any, num: number, key: string) {
|
||||
r[key] = num * 3;
|
||||
return r;
|
||||
}, {});
|
||||
|
||||
result = <any>_.foldl([1, 2, 3], function(sum, num) {
|
||||
result = <any>_.foldl([1, 2, 3], function(sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
result = <any>_.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
|
||||
result[key] = num * 3;
|
||||
return result;
|
||||
result = <any>_.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(r: any, num: number, key: string) {
|
||||
r[key] = num * 3;
|
||||
return r;
|
||||
}, {});
|
||||
|
||||
result = <any>_.inject([1, 2, 3], function(sum, num) {
|
||||
result = <any>_.inject([1, 2, 3], function(sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
result = <any>_.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
|
||||
result[key] = num * 3;
|
||||
return result;
|
||||
result = <any>_.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(r: any, num: number, key: string) {
|
||||
r[key] = num * 3;
|
||||
return r;
|
||||
}, {});
|
||||
|
||||
result = <any>_.reduceRight([[0, 1], [2, 3], [4, 5]], function(a, b) { return a.concat(b); }, []);
|
||||
result = <any>_.foldr([[0, 1], [2, 3], [4, 5]], function(a, b) { return a.concat(b); }, []);
|
||||
result = <any>_.reduceRight([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []);
|
||||
result = <any>_.foldr([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []);
|
||||
|
||||
result = <number[]>_.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
||||
result = <IFoodCombined[]>_.reject(foodsCombined, 'organic');
|
||||
@@ -461,7 +461,7 @@ result = <number[]>_.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
|
||||
result = <number[]>_.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
|
||||
result = <string[]>_.sortBy(['banana', 'strawberry', 'apple'], 'length');
|
||||
|
||||
(function(a, b, c, d){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
||||
(function(a: any, b: any, c: any, d: any){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
||||
|
||||
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'age': 40 });
|
||||
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'quotes': ['Poifect!'] });
|
||||
@@ -470,7 +470,7 @@ result = <IStoogesCombined[]>_.where(stoogesCombined, { 'quotes': ['Poifect!'] }
|
||||
* Functions *
|
||||
*************/
|
||||
var saves = ['profile', 'settings'];
|
||||
var asyncSave = (obj) => obj.done();
|
||||
var asyncSave = (obj: any) => obj.done();
|
||||
var done: Function;
|
||||
|
||||
done = _.after(saves.length, function() {
|
||||
@@ -489,7 +489,7 @@ _.forEach(saves, function(type) {
|
||||
asyncSave({ 'type': type, 'complete': done });
|
||||
});
|
||||
|
||||
var funcBind = function (greeting) { return greeting + ' ' + this.name };
|
||||
var funcBind = function (greeting: string) { return greeting + ' ' + this.name };
|
||||
var funcBind2: () => any = _.bind(funcBind, { 'name': 'moe' }, 'hi');
|
||||
funcBind2();
|
||||
|
||||
@@ -509,7 +509,7 @@ jQuery('#docs').on('click', view.onClick);
|
||||
|
||||
var objectBindKey = {
|
||||
'name': 'moe',
|
||||
'greet': function(greeting) {
|
||||
'greet': function(greeting: string) {
|
||||
return greeting + ' ' + this.name;
|
||||
}
|
||||
};
|
||||
@@ -530,12 +530,12 @@ var realNameMap = {
|
||||
'curly': 'jerome'
|
||||
};
|
||||
|
||||
var format = function(name) {
|
||||
var format = function(name: string) {
|
||||
name = realNameMap[name.toLowerCase()] || name;
|
||||
return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
|
||||
};
|
||||
|
||||
var greet = function(formatted) {
|
||||
var greet = function(formatted: string) {
|
||||
return 'Hiya ' + formatted + '!';
|
||||
};
|
||||
|
||||
@@ -556,7 +556,7 @@ result = <_.LoDashObjectWrapper<Function>>_(function(a, b, c) {
|
||||
console.log(a + b + c);
|
||||
}).curry();
|
||||
|
||||
declare var source;
|
||||
declare var source: any;
|
||||
result = <Function>_.debounce(function() {}, 150);
|
||||
|
||||
jQuery('#postbox').on('click', <Function>_.debounce(function() {}, 300, {
|
||||
@@ -595,7 +595,7 @@ var data = {
|
||||
'curly': { 'name': 'curly', 'age': 60 }
|
||||
};
|
||||
|
||||
var stooge = <Function>_.memoize(function(name) { return data[name]; }, _.identity);
|
||||
var stooge = <Function>_.memoize(function(name: string) { return data[name]; }, _.identity);
|
||||
stooge('curly');
|
||||
|
||||
stooge['cache']['curly'].name = 'jerome';
|
||||
@@ -605,7 +605,7 @@ var initialize = <Function>_.once(function(){ });
|
||||
initialize();
|
||||
initialize();
|
||||
|
||||
var greetPartial = function(greeting, name) { return greeting + ' ' + name; };
|
||||
var greetPartial = function(greeting: string, name: string) { return greeting + ' ' + name; };
|
||||
var hi = <Function>_.partial(greetPartial, 'hi');
|
||||
hi('moe');
|
||||
|
||||
@@ -625,7 +625,7 @@ jQuery('.interactive').on('click', _.throttle(function() { }, 300000, {
|
||||
'trailing': false
|
||||
}));
|
||||
|
||||
var helloWrap = function(name) { return 'hello ' + name; };
|
||||
var helloWrap = function(name: string) { return 'hello ' + name; };
|
||||
var helloWrap2 = _.wrap(helloWrap, function(func) {
|
||||
return 'before, ' + func('moe') + ', after';
|
||||
});
|
||||
@@ -635,22 +635,22 @@ helloWrap2();
|
||||
* Objects *
|
||||
***********/
|
||||
result = <any>_.assign({ 'name': 'moe' }, { 'age': 40 });
|
||||
result = <any>_.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) {
|
||||
result = <any>_.assign({ 'name': 'moe' }, { 'age': 40 }, function(a: any, b: any) {
|
||||
return typeof a == 'undefined' ? b : a;
|
||||
});
|
||||
|
||||
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).assign({ 'age': 40 });
|
||||
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) {
|
||||
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a: any, b: any) {
|
||||
return typeof a == 'undefined' ? b : a;
|
||||
});
|
||||
|
||||
result = <any>_.extend({ 'name': 'moe' }, { 'age': 40 });
|
||||
result = <any>_.extend({ 'name': 'moe' }, { 'age': 40 }, function(a, b) {
|
||||
result = <any>_.extend({ 'name': 'moe' }, { 'age': 40 }, function(a: any, b: any) {
|
||||
return typeof a == 'undefined' ? b : a;
|
||||
});
|
||||
|
||||
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).extend({ 'age': 40 });
|
||||
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) {
|
||||
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a: any, b: any) {
|
||||
return typeof a == 'undefined' ? b : a;
|
||||
});
|
||||
|
||||
@@ -771,9 +771,11 @@ result = <boolean>_.isObject({});
|
||||
result = <boolean>_.isObject([1, 2, 3]);
|
||||
result = <boolean>_.isObject(1);
|
||||
|
||||
function Stooge(name, age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
class Stooge {
|
||||
constructor(
|
||||
public name: string,
|
||||
public age: number
|
||||
) {}
|
||||
}
|
||||
|
||||
result = <boolean>_.isPlainObject(new Stooge('moe', 40));
|
||||
@@ -814,7 +816,7 @@ var mergeOtherFood = {
|
||||
'vegetables': ['carrot']
|
||||
};
|
||||
|
||||
result = <any>_.merge(mergeFood, mergeOtherFood, function(a, b) {
|
||||
result = <any>_.merge(mergeFood, mergeOtherFood, function(a: any, b: any) {
|
||||
return _.isArray(a) ? a.concat(b) : undefined;
|
||||
});
|
||||
|
||||
@@ -832,16 +834,16 @@ result = <any>_.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key)
|
||||
return key.charAt(0) != '_';
|
||||
});
|
||||
|
||||
result = <any>_.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(result, num) {
|
||||
result = <any>_.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r: any, num: number) {
|
||||
num *= num;
|
||||
if (num % 2) {
|
||||
return result.push(num) < 3;
|
||||
return r.push(num) < 3;
|
||||
}
|
||||
});
|
||||
// → [1, 9, 25]
|
||||
|
||||
result = <any>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
|
||||
result[key] = num * 3;
|
||||
result = <any>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(r: any, num: number, key: string) {
|
||||
r[key] = num * 3;
|
||||
});
|
||||
|
||||
result = <any[]>_.values({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
@@ -898,10 +900,16 @@ result = <_.TemplateExecutor>_.template('hello <%= name %>', null, { 'sourceURL'
|
||||
result = <_.TemplateExecutor>_.template('hi <%= data.name %>!', null, { 'variable': 'data' });
|
||||
result = <string>(<_.TemplateExecutor>result).source;
|
||||
|
||||
function Mage() {
|
||||
this.castSpell = (n:number) => n;
|
||||
this.cast = (n: number) => n;
|
||||
};
|
||||
class Mage {
|
||||
public castSpell(n: number) {
|
||||
return n;
|
||||
}
|
||||
|
||||
public cast(n: number) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
var mage = new Mage();
|
||||
result = <any[]>_.times(3, _.partial(_.random, 1, 6));
|
||||
result = <any[]>_.times(3, function(n: number) { mage.castSpell(n); });
|
||||
|
||||
Vendored
+1
-1
@@ -4028,7 +4028,7 @@ declare module _ {
|
||||
}
|
||||
|
||||
interface MemoIterator<T, TResult> {
|
||||
(prev: TResult, curr: T, index: number, list: T[]): TResult;
|
||||
(prev: TResult, curr: T, indexOrKey: any, list?: T[]): TResult;
|
||||
}
|
||||
|
||||
interface Collection<T> { }
|
||||
|
||||
Reference in New Issue
Block a user