How to make WebStorm / TypeScript completion work?

Hi there,

I'm pretty new to Elastic, been using it on and off for about a year, using the JavaScript client.

I finally seem to be at the stage where I understand how to build complex queries, bool, match_phrase_prefix, ids, etc.

However, it's still hard work to remember the exact syntax for each, so my approach is generally:

  • build the query in Kibana using its autocomplete
  • wrap the code in a helper function
  • compose helper function outputs to build queries

However, with either raw POJOs or using the helpers there's not much support in my IDE.

I see that it is possible to get some kind of completion using TypeScript:

I have also installed the global types in WebStorm:

But completion seems to bottom out at the query stage:

Before I went looking for TS support, I had a play with building some type support + helpers, and it worked exactly as I hoped it could:

I could go forward from here and build out TS support for the small subset of features I use, but I figure this is what the Elastic TypeScript package should be doing, no?

I've attempted to import and set the definitions in @elastic/elasticsearch/api in my tsconfig.json's typeRoots but no luck:

    "typeRoots": [


My TS knowledge is pretty good (write and use generics, etc) but there are gaps (this possibly being one!).

Anyway... if you've read through all that, well done, and... what should I be doing to get both completion and type safety / warnings when building queries?


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.