[英]VSCode + Typescript in dockerized React app
I'm running typescript with create-react-app on a local machine for development purposes. 我出于开发目的,在本地计算机上使用create-react-app运行打字稿。 I've gotten rid of the node_modules directory as it's not needed once my image installs the dependencies. 我已经摆脱了node_modules目录,因为一旦我的映像安装了依赖项,就不再需要它。 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. 该应用程序能够在启动时运行,但是我想知道是否有一种方法可以忽略出现的不必要的打字稿警告,因为我的工作目录中没有node_modules。
ie. 即。 [ts] Cannot find module 'react'
, [ts] JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.
[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. 这些不是“不必要的打字稿警告”:tsc告诉您它对React的结构一无所知,因此它无法完成实际检查程序的工作。 By deleting the node_modules
directory you've broken Typescript. 通过删除node_modules
目录,您破坏了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. 重新运行yarn install
或npm install
将重新读取package.json
文件,并带回Typescript编译器(可能是您的应用程序!)需要运行的依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.