简体   繁体   中英

VSCode + Typescript in dockerized React app

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM