# How to use new elasticsearch typescript types

**URL:** <https://discuss.elastic.co/t/how-to-use-new-elasticsearch-typescript-types/281924>\
**Category:** Elasticsearch\
**Created:** [August 19, 2021, 8:06am UTC](https://discuss.elastic.co/t/how-to-use-new-elasticsearch-typescript-types/281924 "2021-08-19T08:06:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![voldemort02](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/voldemort02/32/93404_2.png) [@voldemort02](https://discuss.elastic.co/u/voldemort02)\
**Post date:** [August 19, 2021, 8:06am UTC](https://discuss.elastic.co/t/how-to-use-new-elasticsearch-typescript-types/281924/1 "2021-08-19T08:06:00Z")

</div>

I want to use new elastic search types as per this [TypeScript support | Elasticsearch Node.js client [7.x] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/typescript.html) document but if I do

```auto
// try the new code completion when building a query!
const response = await client.search<Source>({
  index: 'test',
  body: {
    query: {
      match_all: {}
    }
  }
})

// try the new code completion when traversing a response!
const results = response.body.hits.hits.map(hit => hit._source)
// results type will be `Source[]`
console.log(results)

```

my results object itself coming as type I have provided and not coming as SearchResponse

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 16, 2021, 8:06am UTC](https://discuss.elastic.co/t/how-to-use-new-elasticsearch-typescript-types/281924/2 "2021-09-16T08:06:31Z")

</div>

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