简体   繁体   English

dockerized React应用中的VSCode + Typescript

[英]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 installnpm install将重新读取package.json文件,并带回Typescript编译器(可能是您的应用程序!)需要运行的依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Dockerized React 应用程序不重新编译代码 - Dockerized React app not recompiling code 如何在 React/TypeScript 应用程序中的模块方法上获取 VSCode 智能感知? - How to get VSCode intellisense on module methods in a React/TypeScript app? 在 VSCode 或 Chrome 中使用 Typescript 使用 Create React App 调试测试 - Debugging Tests With Create React App using Typescript in VSCode or Chrome 在 dockerized react 应用程序中使用环境变量 - Use enviroment variables in dockerized react app Dockerized React App 无法绑定到 Heroku 上的 $PORT - Dockerized React App failed to bind to $PORT on Heroku 在 Dockerized React 应用程序中使用 IoT Edge 通信 - Using IoT Edge communication in a Dockerized React app 无法访问 Kubernetes 上公开的 Dockerized React 应用程序 - Cannot access exposed Dockerized React app on Kubernetes Node 上的 Dockerized React 应用程序 - 如何复制文件? - Dockerized React app on Node - How to copy files? 如果我在 react-app 中使用 typescript 元组,我会在 vscode 的第 1 行收到 eslint 错误? - If I use a typescript tuple in my react-app i get a eslint error on line 1 in vscode? Dockerized Create React App 不会打开新选项卡 - Dockerized Create React App doesn't open a new tab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM