Closed
Description
TypeScript Version: [email protected]
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.