| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
Sorry, something went wrong.
|
Jack Works (@Jack-Works) please create an issue to track this. I believe Daniel Rosenwasser (@DanielRosenwasser) has some experience about what issues we need to consider for adding a check like this. |
Sorry, something went wrong.
|
Honestly, if the thing on either side is an explicit literal, I don't think there's ever an issue with providing an error. |
Sorry, something went wrong.
|
Do I still need to create an issue since Daniel Rosenwasser (@DanielRosenwasser) replied? |
Sorry, something went wrong.
There was a problem hiding this comment.
Request for one more test
(And I learned that this applies to ==, not just ===)
Sorry, something went wrong.
What test do you want to have? Yes, it applies to == to, although JavaScript can implicit doing a type coherence make the comparison true, TypeScript doesn't consider that case already so I guess it is ok. if (0 == false) {
// This condition will always return 'false' since the types 'number' and 'boolean' have no overlap.(2367)
// but actually true in JavaScript
} |
Sorry, something went wrong.
|
I want to test something that is (1) an existing type error (2) the new object/array literal error: const b = [1]
if ({ a : 1 } == b) { }That's the only addition. |
Sorry, something went wrong.
|
I have resolved the conflict, can you give another review? thanks, Nathan Shively-Sanders (@sandersn) Daniel Rosenwasser (@DanielRosenwasser) |
Sorry, something went wrong.
|
Thanks! I have rebased again to fix merge conflicts. |
Sorry, something went wrong.
|
Looks like a couple of tests still need their baselines updated. |
Sorry, something went wrong.
|
Should we...always show this to JavaScript users? |
Sorry, something went wrong.
Of course, should I do anything to enable this in JavaScript? |
Sorry, something went wrong.
|
Jack Works (@Jack-Works) there is a set of errors to show to JS users in src/compiler/program.ts .. plainJSErrors, I think. Add it there and it will show up for all JS users. There might be cases where == could succeed that might not be appropriate to show, however, so the check might need to be more complex for JS files. |
Sorry, something went wrong.
There're only binder errors and grammar errors in plainJSErrors. Is it ok to add type errors? |
Sorry, something went wrong.
|
Technically, yes. Grammar errors already come from the checker. I vote that we do this for 4.9, after Typescript users have had a chance to report any problems with it. In the past, JS users have gotten irate when code they know to be correct gets a TS error put on it. |
Sorry, something went wrong.
|
I can't think any case that == will return true for either side is literal object 🤔 I will open a PR for it |
Sorry, something went wrong.
|
It could be surfaced as a suggestion, right? I do agree that we should be a little conservative on things like this for JS users. |
Sorry, something went wrong.
But that's definitely a mistake even you're using JS 🤔 |
Sorry, something went wrong.
|
Also, suggestions ought to provide a codefix. And their default UI in vscode is extremely subtle. |
Sorry, something went wrong.
|
In this case I cannot provide a code fix because it really depends on the intension of the code 🤔 |
Sorry, something went wrong.
|
I think we should ship this as an error in 4.9 for JS, perhaps with some more restrictions to cut down on false positives. |
Sorry, something went wrong.
|
Can you give an example of false positives on this error? 😂 I can't think any of it |
Sorry, something went wrong.
|
I commented on the PR. So far they all look like intentionally bad code, so there might not be anything to do. |
Sorry, something went wrong.
[1,2,3] == '1,2,3'
// -> true
({toString() { return 1 }}) == 1
// -> true== is super sketchy due to its coercion
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.