javascript - 为什么我的 create-react-app 项目在编译时会输出数千行关于类型的警告?
问题描述
我正在接管一个遗留项目。我主要是一名后端程序员,而不是最新的 JS 构建工具。我试图弄清楚这个项目是如何组合在一起的。该项目使用react-app-rewired。在服务器准备好之前npm run start-js
产生大量的输出。在服务器准备好之前的 2 分钟,对于 10s 的数千行,它看起来像这样:
======== Resolving type reference directive 'async', containing file '/vagrant/client/__inferred type names__.ts', root directory '/vagrant/client/node_modules/@types'. ========
Resolving with primary search path '/vagrant/client/node_modules/@types'.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
'package.json' has 'main' field '' that references '/vagrant/client/node_modules/@types/async'.
Found 'package.json' at '/vagrant/client/node_modules/@types/async/package.json'. Package ID is '@types/async/.d.ts@2.0.47'.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
File '/vagrant/client/node_modules/@types/async/index.d.ts' exist - use it as a name resolution result.
Resolving real path for '/vagrant/client/node_modules/@types/async/index.d.ts', result '/vagrant/client/node_modules/@types/async/index.d.ts'.
======== Type reference directive 'async' was successfully resolved to '/vagrant/client/node_modules/@types/async/index.d.ts', primary: true. ========
======== Resolving type reference directive 'chrome', containing file '/vagrant/client/__inferred type names__.ts', root directory '/vagrant/client/node_modules/@types'. ========
和更多:
Resolution for module 'apollo-mutation-state' was found in cache from location '/vagrant/client/src/containers/users'.
======== Module name 'apollo-mutation-state' was successfully resolved to '/vagrant/client/node_modules/apollo-mutation-state/lib/index.js'. ========
======== Resolving module 'graphql/auth/signInMutation.graphql' from '/vagrant/client/src/containers/users/SetResetPassword.tsx'. ========
Resolution for module 'graphql/auth/signInMutation.graphql' was found in cache from location '/vagrant/client/src/containers/users'.
======== Module name 'graphql/auth/signInMutation.graphql' was not resolved. ========
======== Resolving module 'moment-timezone' from '/vagrant/client/src/containers/users/SetResetPassword.tsx'. ========
Resolution for module 'moment-timezone' was found in cache from location '/vagrant/client/src/containers/users'.
======== Module name 'moment-timezone' was successfully resolved to '/vagrant/client/node_modules/@types/moment-timezone/index.d.ts'. ========
======== Resolving module 'components/form/validation' from '/vagrant/client/src/containers/users/SetResetPassword.tsx'. ========
Resolution for module 'components/form/validation' was found in cache from location '/vagrant/client/src/containers/users'.
======== Module name 'components/form/validation' was successfully resolved to '/vagrant/client/src/components/form/validation.ts'. ========
======== Resolving module 'types' from '/vagrant/client/src/containers/users/SetResetPassword.tsx'. ========
Resolution for module 'types' was found in cache from location '/vagrant/client/src/containers/users'.
======== Module name 'types' was successfully resolved to '/vagrant/client/src/types.ts'. ========
======== Resolving module 'react' from '/vagrant/client/src/containers/users/SignInUserWrapper.tsx'. ========
Resolution for module 'react' was found in cache from location '/vagrant/client/src/containers/users'.
======== Module name 'react' was successfully resolved to '/vagrant/client/node_modules/@types/react/index.d.ts'. ========
和更多:
Directory '/vagrant/client/src/containers/conversations/node_modules' does not exist, skipping all lookups in it.
Directory '/vagrant/client/src/containers/node_modules' does not exist, skipping all lookups in it.
Directory '/vagrant/client/src/node_modules' does not exist, skipping all lookups in it.
(node_modules 在/vagrant/client/node_modules
)
然后它确实成功了,我所有的 JS 都按预期工作。我猜搜索路径或其他东西配置错误。这是怎么回事?这是正常行为吗?这都是关于类型的,还是其他的?
版本
- typescript 2.9.2(也尝试过 3.4.3,似乎是相同的行为)
- 反应脚本-ts 2.17.0
- react-app-rewired 1.6.2
- 反应^16.3.0
解决方案
这些消息似乎根本不是警告。事实上,他们说该模块已成功解决。
尝试"traceResolution": false,
在compilerOptions
您的tsconfig.json
文件中添加。
推荐阅读
- ajax - 如何触发
我需要触发面板内的 ajax 事件,并且面板位于 ac:forEach 内,我该怎么做?我尝试这样做并放置示例的方式,它不会触发 bean 中的事件。
这是xhtml:
<p:panel header="Configuração de Dashboard"> <p:d
- vb.net - 如何从我的表单上的按钮单击另一个程序上的按钮?
- javascript - 量角器:如果一个场景失败,如何解决承诺并停止跳过场景
- vue.js - 来自祖父母的组件,来自父母的数据,在孩子中呈现
- c# - .NET Core 和 .NET Framework 之间的 CultureInfo 不同
- r - 在 R 中找到一个截止值
- java - 如何禁用 Spring 执行器的内容协商?
- android - Android更改默认权限保护级别
- c# - 并行运行计算繁重任务而不等待 C# 中的结果
- python-3.x - Python unittest 未从指定目录运行