We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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:
$.each<string>(...)
The text was updated successfully, but these errors were encountered:
Also, replacing return this != 'abc' with return this.indexOf('x') != 0 works. It seems related specifically to the binary operator with this.
return this != 'abc'
return this.indexOf('x') != 0
this
Sorry, something went wrong.
Well, that's only VS Code apparently. Now that I'm running a test case from the command line, this.indexOf('x') fails with the same error.
this.indexOf('x')
A fix is up at #9746, although I need some expert help to make sure it's the correct fix (it's hacky, so it's probably not correct yet).
sandersn
Successfully merging a pull request may close this issue.
TypeScript Version: [email protected]
Code
Expected behavior:
No errors
Actual behavior:
Operator '!=' cannot be applied to types 'T' and 'string'.
Notes:
$.each<string>(...)
, although the type is correctly inferred to string even without it.The text was updated successfully, but these errors were encountered: