TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

autoImportSpecifierExcludeRegexes needs a window refresh for changes to take effect

Open 188599 opened this issue 1 year ago • 7 comments

🔎 Search Terms

autoImportSpecifierExcludeRegexes

🕗 Version & Regression Information

  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

No response

💻 Code

.vscode/settings.json

{
  "<language>.preferences.autoImportSpecifierExcludeRegexes": ["<regex>"]
}

🙁 Actual behavior

Changes only take effect after a window reload.

🙂 Expected behavior

Changes to take effect immediately, same way that autoImportFileExcludePatterns does.

Additional information about the issue

I mentioned this earlier on another issue (https://github.com/microsoft/TypeScript/issues/35395#issuecomment-2371010892) and I initially thought that the update I got fixed the problem, turns out it was just because that forced the window to refresh, as I later encountered the same problem once I tried adding new regexes to it.

188599 avatar Sep 27 '24 09:09 188599

@mjbvz checked manually and I don't see anything in the server log where the updated setting gets sent over

RyanCavanaugh avatar Sep 27 '24 15:09 RyanCavanaugh

@188599 What VS Code version are you using? Support for this setting was only added in the last month

mjbvz avatar Sep 27 '24 15:09 mjbvz

@188599 What VS Code version are you using? Support for this setting was only added in the last month

1.94-insider

188599 avatar Sep 27 '24 19:09 188599

@RyanCavanaugh Can you also tru this out on in insiders. I see the field getting sent over in the configure request for the file:

Image

mjbvz avatar Sep 27 '24 19:09 mjbvz

This is only tangentially related to the issue, but as I was digging through the code trying to figure out why autoImportFileExcludePatterns was seemingly not working as intended, with the code provided on a new Ionic project, they bundle it in with the following:

.vscode/settings.json

{
  "typescript.preferences.autoImportFileExcludePatterns": ["@ionic/angular/commons", "@ionic/angular"]
}

And instead of excluding those 2 import paths, it was removing all import paths under @ionic/angular, where the required imports are all from @ionic/angular/standalone.

It seemed to me that due to recent changes to autoImportFileExcludePatterns the old behavior was changed and this why autoImportSpecifierExcludeRegexes came about to make up for it.

What I was left wondering is, is the current behavior from autoImportFileExcludePatterns mentioned above intended? It feels like it shouldn't be either.

188599 avatar Sep 27 '24 19:09 188599

{ "typescript.preferences.autoImportFileExcludePatterns": ["@ionic/angular/commons", "@ionic/angular"] }

Same issues here (including the one from the OP). As a workaround for Ionic, I'm using:

{
    "typescript.preferences.autoImportSpecifierExcludeRegexes": ["^@ionic\/angular\/common$", "^@ionic\/angular$", "\/proxies$"]
}

kafumanto avatar Nov 06 '24 20:11 kafumanto

autoImportSpecifierExcludeRegexes needs a window refresh for changes to take effect

Same here. Though restarting the TS server also works.

tusharsnx avatar Apr 05 '25 09:04 tusharsnx