Skip to content

TS2339 refactoring warnings (three gray dots) appearing under javascript properties #46103

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

Closed
aminomancer opened this issue Sep 22, 2021 · 5 comments · Fixed by #46151
Closed
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@aminomancer
Copy link

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

  • VS Code Version: 1.60.2 (user setup)
  • OS Version: Windows 10 Pro 20H2, 19042.1165, Windows Feature Experience Pack 120.2212.3530.0

Steps to Reproduce:

I have a JavaScript file. It declares & defines a variable in the topmost scope, like const options = {};
Then, at some dynamic point during runtime, user configuration values (properties) are cloned from local storage into this options object:
for (const [key, field] of Object.entries(storage)) options[key] = field.value;

So obviously TypeScript validator thinks options.blahblah does not exist. Which is fine, I don't expect it to. But instead of just creating a lightbulb icon to the left when I click on its general area, it adds 3 dots under the beginning of the property name, which appear no matter what I do. They're showing 100% of the time. When I have dozens of properties being referenced all over the place, these little dotted underlines cause a large amount of visual clutter.

It's irritating because there's nothing wrong with my script, but vs code keeps treating it as somehow erroneous and shoving it in my face. It doesn't give me any valuable refactoring suggestions either. Astonishingly, it clutters my document with a hundred of these warnings, only to recommend "extracting to Fluent files" in each case. Obviously that suggestion is completely irrelevant to my use case.

I just want some way to shut this off. When I originally wrote this script some months ago, and validated it with ESLint, these gray dots did not exist. It's only when I came back to update it that I noticed the warnings. Naturally I went digging through the settings, but could not find anything that sounded relevant. I did some google searches and found people talking about other representations of the same rule (2339) in vs code extensions. But I couldn't find any solution or suggestion for disabling it in the TS/JS validator of vs code proper.

So I just went ahead and started blindly unchecking boxes in the settings. I figured eventually I'd reload vs code and see the dotted underlines are gone, but no such luck. So I'm wondering if a setting to disable this even exists.

Thank you 🙏

@mjbvz
Copy link
Contributor

mjbvz commented Sep 27, 2021

Please share a self contained block of code that demonstrates the issue

@aminomancer
Copy link
Author

Oh, thought I already did. Is this better?

let a = {};
let b = {
    apple: true,
    banana: false,
    grape: undefined,
    lychee: null,
};
for (const [key, val] of Object.entries(b)) a[key] = val;
console.log(a.apple);

If that's unclear you can take a look at the greasemonkey script I described in my first post, which was suddenly filled with dotted underlines a month or two ago.

To be clear, I don't expect VS code to recognize that the for loop I described above would define apple on a. I understand that would be substantially more computationally expensive than what it's currently doing. I just want some way to turn off the 3 dots display, because it's making my editors so cluttered and causing me to waste time reexamining code that isn't defective, for an alert that offers no refactoring suggestions anyway.

However, I would prefer if there was a way to keep the 3 dots display for other refactoring suggestions that are relevant, and only turn off the complaint for rule TS2339: Property 'foo' does not exist on type 'bar'.

@mjbvz mjbvz transferred this issue from microsoft/vscode Sep 27, 2021
@mjbvz mjbvz removed their assignment Sep 27, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Sep 27, 2021

@sandersn I think this started with TS 4.4, possibly due to the spelling suggestion work?

@sandersn
Copy link
Member

I confirmed that it's an unintended effect of that PR (#44271). I'll figure out why other, unwanted suggestions are showing up.

@sandersn sandersn added this to the TypeScript 4.5.1 milestone Sep 30, 2021
@sandersn sandersn self-assigned this Sep 30, 2021
@sandersn sandersn added the Bug A bug in TypeScript label Sep 30, 2021
@sandersn
Copy link
Member

reportNonExistentProperty can report several kinds of errors, most of which do not contain spelling suggestions. Currently, all these errors are getting turned into suggestions. Only the did-you-mean ones should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants