Search code examples
javascriptreactjstypescriptcreate-react-app

Why does my create-react-app project output thousands of lines of warnings about types while compiling?


I'm taking over a legacy project. I'm mostly a backend programmer and not up on the latest JS build tools. I'm trying to figure out how the project is put together. The project uses react-app-rewired. npm run start-js produces an enormous amount of output before the server is ready. It looks like this, for 10s of thousands of lines, for 2 minutes before the server is ready:

======== 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/[email protected]'.
'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'. ========

and more:

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'. ========

and more:

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.

(the node_modules are in /vagrant/client/node_modules)

Then it does succeed and all my JS works as expected. I'm guessing there is something misconfigured with search paths or something. What's going on? Is this normal behavior? Is this all about types, or other things as well?

Versions

  • typescript 2.9.2 (also tried 3.4.3, seems to be same behavior)
  • react-scripts-ts 2.17.0
  • react-app-rewired 1.6.2
  • react ^16.3.0

Solution

  • Those messages don't seem to be warnings at all. In fact they say that the module has been resolved successfully.

    Try adding "traceResolution": false, under compilerOptions in your tsconfig.json file.