-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
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.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue