From de27dd9697bb9f4aab6c50c50c3c8d4666b78197 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 12 Apr 2022 10:34:56 +0200 Subject: [PATCH] [Backport 8.2] Update TypeScript docs and export estypes (#1676) Co-authored-by: Tomas Della Vedova --- .github/ISSUE_TEMPLATE/regression.md | 1 + docs/typescript.asciidoc | 11 +++++++++++ index.d.ts | 2 ++ 3 files changed, 14 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/regression.md b/.github/ISSUE_TEMPLATE/regression.md index b3c6c2606..7984b3129 100644 --- a/.github/ISSUE_TEMPLATE/regression.md +++ b/.github/ISSUE_TEMPLATE/regression.md @@ -51,5 +51,6 @@ Paste the results here: - *node version*: 6,8,10 - `@elastic/elasticsearch` *version*: >=7.0.0 +- *typescript version*: 4.x (if applicable) - *os*: Mac, Windows, Linux - *any other relevant information* diff --git a/docs/typescript.asciidoc b/docs/typescript.asciidoc index 86ca67389..becaf488b 100644 --- a/docs/typescript.asciidoc +++ b/docs/typescript.asciidoc @@ -7,6 +7,10 @@ of type definitions of Elasticsearch's API surface. The types are not 100% complete yet. Some APIs are missing (the newest ones, e.g. EQL), and others may contain some errors, but we are continuously pushing fixes & improvements. +NOTE: The client is developed against the https://www.npmjs.com/package/typescript?activeTab=versions[latest] +version of TypeScript. Furthermore, unless you have set `skipLibCheck` to `true`, +you should configure `esModuleInterop` to `true`. + [discrete] ==== Example @@ -77,3 +81,10 @@ You can import the full TypeScript requests & responses definitions as it follow ---- import { estypes } from '@elastic/elasticsearch' ---- + +If you need the legacy definitions with the body, you can do the following: + +[source,ts] +---- +import { estypesWithBody } from '@elastic/elasticsearch' +---- \ No newline at end of file diff --git a/index.d.ts b/index.d.ts index 8fb595c75..2fbbb3652 100644 --- a/index.d.ts +++ b/index.d.ts @@ -21,5 +21,7 @@ import Client from './lib/client' import SniffingTransport from './lib/sniffingTransport' export * from '@elastic/transport' +export * as estypes from './lib/api/types' +export * as estypesWithBody from './lib/api/types' export { Client, SniffingTransport } export type { ClientOptions, NodeOptions } from './lib/client'