Reputation: 731
I am developing a app with React-Native and I am using vscode as a code editor. When I import some image or package, I got these red and yellow underline error. How to fix this?
One thing that I can't understand is only "Fontawesome" has no such error, but both "MaterialCommunityIcons" and "Ionicons" have red underline error. (Line 4,5,6)
When I mouse over the line 1 yellow underline, it shows me following.
ESLint is disabled since its execution has not been approved or denied yet. Use the light bulb menu to open the approval dialog.
When I mouse over the line 5,6 red underline, it shows me following.
Could not find a declaration file for module 'react-native-vector-icons/MaterialCommunityIcons'.
I uninstall and installed "react-native-vector-icons" package several times but same error.(exactly not error, I think just type error. Code working well.) I installed following extensions.
Upvotes: 2
Views: 15799
Reputation: 31
You can add this line at the top of your code :
/* eslint-disable prettier/prettier */
This line disables eslint extension which solve the problem in my case
Upvotes: 0
Reputation: 21
easy way to get rid of it: disable the Eslint Extension and reload the vs code
Upvotes: 1
Reputation: 2185
It would be fitting to post separate questions for these, but:
This might have several reasons, but given the error message please try the following method in the command palette and allowing ESLint access:
cmd + shift + p
, search for 'ESLint: Manage Library Execution'
Otherwise you can check other solutions eg. here: ESLint not working in VS Code?
MaterialCommunityIcons
type declaration missing error:Perhaps you have not installed the corresponding types - do so by running:
yarn install @types/react-native-vector-icons -D
*.png
error:By default, typescript does not understand *.png
files. You can fix this by adding a *.d.ts
(eg. assets.d.ts
) file (eg. in a top-level types
folder), with the following contents:
declare module '*.png' {
const value: any;
export = value;
}
Make sure the file is at a path typescript can find (must be listed in the compilerOptions.include
property in your tsconfig.json
).
Upvotes: 4