Geoff Garbers

Husband. Programmer. Tinkerer.

React and PropType autocompletion in WebStorm

Mar 09, 2018

I was struggling to get React and PropType autocompletion working in my WebStorm installation when working on a codebase that consists of multiple top-level folders:

/
  admin/
    index.js
    index.html
  frontend/       <--- React application resides here.
    index.js
    index.html
  server/
    index.php

I went through a number of different solutions trying to get autocompletion working (including installing the @types/react and @types/prop-types NPM packages).

However, I found that there was only one solution that ended up working:

The solution is as simple as not excluding the specific packages in your node_modules directory (WebStorm excludes the node_modules directory by default - which means nothing in these directories are indexed). Once I included node_modules/prop-types and node_modules/react, autocompetion starting working as I expected it to.