microsoft / microsoft/TypeScript

`js/ts.preferences.autoImportFileExcludePatterns` is not reflected promptly in IntelliSense suggestions

Open
#63,498 1 comment 2 reactions 0 assignees View on GitHub
Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### 🔎 Search Terms

autoImportFileExcludePatterns

### 🕗 Version & Regression Information

- I test this in 4.8.4, 6.0.3 and tsgo 0.20260520.1

### ⏯ Playground Link

_No response_

### 💻 Code
in `.vscode/settings.json`
```json
"js/ts.preferences.autoImportFileExcludePatterns": [
//"**/node_modules/@types/node",
// "node",
"fs.d.ts",
// "node_modules/@types/node/fs.d.ts",
// "node:fs"
]
```

a.ts

```ts
readFileSync('','');
readF
```

### 🙁 Actual behavior

In VSCode,
when repeatedly toggling `"fs.d.ts"` in the config above:
Normal part: you will find that for the first line `readFileSync('','')`, the `Quick Fix` menu item like `import from "fs"` will appear or disappear as expected when `"fs.d.ts"` is added or removed from the config.
But for the case when you type `readF` and trigger IntelliSense, whether `readFileSync...` appears in the completion suggestions is unpredictable. Sometimes using "Reload Window" can fix it, but in most cases, it doesn't work as expected—toggling `"fs.d.ts"` doesn't immediately change the current IntelliSense state.

### 🙂 Expected behavior

For the above example, after modifying `"js/ts.preferences.autoImportFileExcludePatterns"` in the VSCode config, I expect the IntelliSense suggestions to reflect the changes immediately.

### Additional information about the issue

There is a similar issue: https://github.com/microsoft/TypeScript/issues/60082
However, that one is a bit old and the phenomenon I described is somewhat different.

Additionally, I have a question: For the setting `js/ts.preferences.autoImportFileExcludePatterns`, does it only match a single file, or does it match the `xxx` part in` import ... from 'xxx'`? After all, a single file can define multiple modules, and multiple "exports" can also be defined in `package.json`.

Contributor guide

Open the contributing guide

Research direction

Start with the reproduction in .vscode/settings.json and a.ts, toggling fs.d.ts while comparing Quick Fix behavior with IntelliSense completion suggestions. Trace the configuration handling for js/ts.preferences.autoImportFileExcludePatterns and the completion state it affects. Done means changing the setting updates the current IntelliSense suggestions immediately and the reported reproduction is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.