首页 > 解决方案 > 为什么我的 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 都按预期工作。我猜搜索路径或其他东西配置错误。这是怎么回事?这是正常行为吗?这都是关于类型的,还是其他的?

版本

标签: javascriptreactjstypescriptcreate-react-app

解决方案


这些消息似乎根本不是警告。事实上,他们说该模块已成功解决。

尝试"traceResolution": false,compilerOptions您的tsconfig.json文件中添加。


推荐阅读