Option to exclude patterns from auto import not working?

Viewed 51

There's this new feature with Typescript 4.8 that allows you to prevent auto import from suggesting files or packages, but I can't seem to make it work.

This is the workspace setting that I have:

{
  "typescript.preferences.autoImportFileExcludePatterns": [
    "@stitches/react"
  ]
}

But then when I try to import in VS Code it still suggests the library.

I'm sure the settings are being applied because I tested adding another setting in the same file and that setting worked.

1 Answers

I figured it out myself. Turns out that VS Code was running Typescript 4.7 internally, which doesn't support the new setting.

I had to set VS Code's Typescript's version to the same one as in my node_modules by adding typescript.tsdk to my settings:

{
  "typescript.tsdk": "node_modules/typescript/lib",
  "typescript.preferences.autoImportFileExcludePatterns": ["@stitches/react"]
}
Related