1

I was working on a react-native project (not using typescript). All of a sudden I noticed I could not use react native APIs with auto-completion. When hovering over react native import get the warning "Could not find a declaration file for module 'react-native' ../node_modules/react-native/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/react-native if it exists or add a new declaration (.d.ts) file containing declare module 'react-native'; ". once again I'm not using typescript

P.S: I forgot to mention that I'm using expo sdk 44

2 Answers 2

1

That error is very common, and can mean a huge variety of things. One thing it never is - is anything that has to do with Typescript. That's a big red-herring and don't waste your time searching for a solution in regards to that.

I'd suggest a full restart and cleaning of your project, and then the error messages are usually more specific. So clear your cache, restart your computer, delete node_modules and then npm install again.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your response. I planned on deleting the node module and npm intall all over again but got an error. I then created another project and copy-pasted the previous code. All works fine but i still got this warning. It's not preventing my code from running but I can't use react native APIs like before and it's very frustrating.
Yea it's certainly frustrating. I know it sounds odd, but I often have an error in my work on like the landing screen, and React Native will still compile and run. Later on when I restart my work and land on that screen it will tell me the exact error. Don't worry about it too much, and I'm sure it'll pop up later. Just don't mess around with Typescript stuff cause I can ensure you that's not the real problem.
Sure the issue isn't typescript related. And you might be right because the problem occured out of a blue and now all react-native project I'm initiating comes with that warning. I hope it vanishes the same way it appeared
I'm trying to use a react-native aliased to react-native-web package in nextjs and getting this. Same error on the build server too. Not sure what to check for now.
-1

I had the same issue and the cause was due to this syntax error of 2 className property tags on an element, in another component file of my app, see below:

return (
    <View 
        className="bg-purple-600 rounded-lg rounded-tr-none px-5 py-3 mx-3 my-2"
        className="bg-red-400 rounded-lg rounded-tl-none px-5 py-3 mx-3 my-2 ml-14"
    >
        // content
    </View>
);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.