Reputation: 121
I'm running typescript with create-react-app on a local machine for development purposes. I've gotten rid of the node_modules directory as it's not needed once my image installs the dependencies. The app is able to run when I start it, but I want to know if there's a way to ignore unnecessary typescript warnings that are surfacing because I don't have the node_modules in my working directory.
ie. [ts] Cannot find module 'react'
, [ts] JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.
Upvotes: 2
Views: 2778
Reputation: 159771
Those aren't "unnecessary typescript warnings": tsc is telling you that it doesn't know anything about the structure of, in this case, React, and so it can't do the job of actually checking your program. By deleting the node_modules
directory you've broken Typescript.
This is easy to fix. Re-running yarn install
or npm install
will re-read your package.json
file and bring back the dependencies that the Typescript compiler (and presumably your application!) needs to run.
Upvotes: 3