Visual Studio Code typescript auto import not working

Viewed 1874

As the title stated my VS Code doesn't auto import my modules, I'm trying to import MatDialogModule in the image below and it doesn't show me any Angular Material options

enter image description here

4 Answers

For Angular 13, below solution worked for me: Add this in tsconfig.json under compilerOptions.

"typeRoots": ["node_modules/@angular/material"]

VSCode is not able to auto import module from directories which have more than two path segments. However, this is true only for the first time you import a module inside a project.

It's worth checking if you have done this first, import { MatDialogModule } from '@angular/material/dialog';, as the type comes from /dialog directory.

It'd also be more helpful if you could attach your package.json file to your question, and show what you have installed so far. Did you use Angular CLI to install the Material modules?

You might find following links helpful:

As woodykiddy said, is @angular/material a dependency in your package.json? If not, add it and run npm i or yarn or the install command for your chosen package manager.

Related