Skip to content
New issue

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

js/ts.implicitProjectConfig.checkJs error underlining something as not working, but it is #168726

Closed
1Euro7Cent opened this issue Dec 10, 2022 · 2 comments
Assignees
Labels
upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@1Euro7Cent
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • Version: 1.74.0 (user setup)
    Commit: 5235c6b
    Date: 2022-12-05T16:38:16.075Z
    Electron: 19.1.8
    Chromium: 102.0.5005.167
    Node.js: 16.14.2
    V8: 10.2.154.15-electron.0
    OS: Windows_NT x64 10.0.19044
    Sandboxed: No

Steps to Reproduce:

  1. have "js/ts.implicitProjectConfig.checkJs": true, in the settings.json
  2. have the following block in a .js file:
const b = "something"

class A {
    constructor() {
        this.b = "something"
    }
    toString() {
        return this.b
    }
}
let a = new A()
if (a == b) { // it undelines this with error: This comparison appears to be unintentional because the types 'A' and 'string' have no overlap.
    console.log("it is true")
}
else {
    console.log("it is false")
}

when I run it I get it is true in the console

It seems like it does not check if there is a toString function in that class. In boolean comparisons NodeJS autocalls that function before comparing.

@IllusionMH
Copy link
Contributor

TS doesn't work nicely with non-strict equal, and also doesn't use toString or valueOf. (see microsoft/TypeScript#2361)

@mjbvz
Copy link
Collaborator

mjbvz commented Dec 13, 2022

Closing as upstream

(Honestly you should probably refactor any code that does this though)

@mjbvz mjbvz closed this as completed Dec 13, 2022
@mjbvz mjbvz added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Dec 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

3 participants