Closed
Description
TypeScript Version: typescript@2.1.0-dev.20160713
Code
interface JQuery {
each<T>(
collection: T[],
callback: (this: T, indexInArray: number, valueOfElement: T) => any
): any;
}
let $: JQuery;
let list: string[];
$.each(list, function() {
return this != 'abc';
});
Expected behavior:
No errors
Actual behavior:
Operator '!=' cannot be applied to types 'T' and 'string'.
Notes:
- Explicit 'string' type parameter fixes the error:
$.each<string>(...)
, although the type is correctly inferred to string even without it.