I have recently started working with vs code. I am using material ui with react and type script. But I am not able to import the components of material ui using alt(option)
I believe I can reproduce the problem you are seeing. Based on my testing, the auto-import functionality built into VS Code only works for symbols defined in files that are already loaded as part of your project because they match, or are directly or indirectly imported by files that match, the include
setting in tsconfig.json
. (See this thread for some background.)
I started with your configuration files and a blank source file but removed @types/material-ui
because it's for the old material-ui
package (which you don't have installed) and is just confusing matters. At this point, if I invoke code completion with Ctrl-Space, I am not offered the Material UI components (AppBar
, Avatar
, ...). But if I add an import, for example import { AppBar } from "@material-ui/core";
, that forces the TypeScript server to load @material-ui/core
, so now if I invoke code completion again, I am offered the rest of the Material UI components. If you need auto import to work without an existing import, then you could add the appropriate .d.ts
files to the include
list in tsconfig.json
, although then you'd want to use a separate tsconfig.json
file for batch compilation so that you don't try to overwrite the JavaScript files in the @material-ui/core
package.
I haven't tested any third-party auto-import plugins and can't speak about their behavior.