Check out the Auto Import plugin by steoates for VS Code
Answer from Kunal on Stack OverflowVS Code Auto Import is bugging. Or I am stupid.
Auto imports imports from 'react-native/types' instead of 'react-native'
How to prevent VS Code auto importing from 'react-native-web'? - Stack Overflow
configure vscode react native auto-imports without ts errors
Videos
Recently, every time I want to import a hook it brings this option.https://imgur.com/a/tRnxml8
BEFORE:
import { useState } from "react";
AFTER
import { useState } from "react/cjs/react.production.min";
or
import { useState } from "react/cjs/react.development";Did I screw up something or is this normal? I don't even know what to google to fix this. Thanks.
Fix:
https://github.com/microsoft/TypeScript/issues/47601
I don't understand why you need a config for auto imports, but you could install the Auto import snippet from VSC snippets, here is the link try it.
also, the error from your typescript is not related to the auto import, it is a typescript error, your touchableOpacity still missing some props.
The best way is to create jsconfig.json and type in:
{
"compilerOptions": {
"module": "CommonJS",
"jsx": "preserve",
"checkJs": true
},
"exclude": ["node_modules", "**/node_modules/*"]
}
You might have the 'Auto Imports' option disabled.
In VSCode go to Settings and search for 'Auto Imports' option, it should be something like this:

Just activate it if it's disabled and you'll be fine.
If you have already checked and enabled 'Javascript: Auto Import' in the User setting but it still doesn't work, it might still be some other causes that you hadn't aware of:
- Check higher priority preference which's Workspace setting, in the tab next to User in the Setting window. In case you prefer configuration in the script. There's a file setting.json resides in the .vscode folder
Additional information: In your project/workspace root folder, look for the folder with the name ".vscode" and the "setting.json" file, in there storing preferences that affect to only what's inside the workspace. Look for anything that may cause the unintended settings and update it following your demand.
If you can not find anything like that. Then try re-install whatever "Auto import" extension you are using. Reload the editor and try again. Most of my editor errors were fixed by just simply reloading the editor.
Hope that might help!
I am using vscode with vite to create a new react project.
I am running into problems with the auto import features of visual studio.
Any node_modules dependency does not get suggested for auto import. I have other projects on this machine and when i switch to them the auto import works exactly how I would expect.
Does anyone know what the issue could be?
Update 2018
VS Code now handles this natively via a jsconfig.json and the JavaScript Language Service.
Create the file jsconfig.json at your project root and make sure to set checkJs to true:
Creating a JS Config file, allows Visual Studio to treat the folder as an Explicit Project. Without it, JS files opened in VS Code are treated as independent units, and there is no common project context between any two files.
Example:
{
"compilerOptions": {
"baseUrl": "./src",
"checkJs": true,
"jsx": "react"
}
}
Code Action / Quick Fix
Missing modules will show up with a Code Action (AKA "Quick Fix") with an option to import. You can click on the lightbulb 💡 or use Ctrl + .

Auto Imports / IntelliSense
Auto Imports will show you available components as you type and import them when selected

Further Reading
- Visual Studio Code Automatic Imports
- How to add jsconfig.json to existing vscode project w/o breaking it
Double check that the extension is enabled by navigating to Extensions > searching for "Auto Import". You should see the following:
