Steps to Reproduce:
clearTimeoutimport { clearTimeout } from 'timers' imported without asking and error in the browser.Reported here already:
https://github.com/Microsoft/vscode/issues/57822
https://github.com/Microsoft/vscode/issues/40001
https://github.com/Microsoft/vscode/issues/38911
Is it impossible for VS Code to know that I write code for a browser where these are available already, and should not import them?
Does this issue occur when all extensions are disabled?: Yes/No - no idea
I think this is a duplicate of #15024.
I don't think it's a duplicate of #15024 because that issue says to favor local variables while this issue is about why existing global properties of the window object are being shadowed with something auto imported. This was and will be reported probably in the future because it doesn't seem like there is any interest in fixing this.
I see both in my completion list, which is probably even worse (since it's hard to tell them apart). If something in the lexical scope exists, we shouldn't offer it at all as an auto-import
this is how i do it:
window.setTimeout(...) // <-- right signature is picked
it's back to the question about annoying ambients https://github.com/Microsoft/TypeScript/issues/14306
@csicky I'm trying to track down how and when the worst-case scenario is happening. Like Ryan, I see both completions, and the global one is always the top one and always selected, so for me, clearTimeout never gets accidentally imported because I have to press the down arrow key to select the auto-import. Could you help me try to reproduce your exact problem?
tsconfig.json file anywhere in your project?clearTimeout? Here’s what I see:
editor.suggest?Yes I have this one: "editor.suggest.localityBonus": true,
Right now I have re-enabled the import setting and like you said, the globals are now on top of the list. The auto import was on top at the time I opened this issue, so that is fixed.
Still, I think that there shouldn't be so confusing imports shadowing globals like in the following image:

I am not sure which setting is responsible for the auto import in a .vue file component in a project without TypeScript. For this test I enabled all 3 of them (temporarily).
"typescript.suggest.autoImports": true,
"javascript.suggest.autoImports": true,
"vetur.completion.autoImport": true,
For public visibility: I do have a PR up at #31065, but I don't like it very much. Given this:
the globals are now on top of the list. The auto import was on top at the time I opened this issue, so that is fixed.
I've changed the milestone to 3.6 and plan to revisit this and see if we can come up with some better heuristics after 3.5 is released.
Woops, this should have been closed with #31893. The "fixed" label kept it from showing up in my usual query.
Most helpful comment
Yes I have this one:
"editor.suggest.localityBonus": true,Right now I have re-enabled the import setting and like you said, the globals are now on top of the list. The auto import was on top at the time I opened this issue, so that is fixed.
Still, I think that there shouldn't be so confusing imports shadowing globals like in the following image:

I am not sure which setting is responsible for the auto import in a
.vuefile component in a project without TypeScript. For this test I enabled all 3 of them (temporarily).