Skip to content

Inability to import your official types e.g. IndexRequest, SearchResponse etc. #2612

Closed
@jdickie

Description

@jdickie

Question

Background

We operate a project that uses Typescript, Lambda and Elasticsearch. We've been using your elasticsearch package for some time, and recently I have been working to upgrade our local version to your latest - 8.17.0 from 8.15.1.

The problem

We have declarations like the following that no longer work (Typescript throws a compiler error):

import { IndexRequest, SearchResponse } from '@elastic/elasticsearch/lib/api/types';

// ...

const params: IndexRequest<AuthorizedClient> = {
            index: AUTH_DOCUMENT_INDEX,
            id: client.id,
            document: client,
        };

The above used to be fine with tsc, but now it throws an error:

error TS2307: Cannot find module '@elastic/elasticsearch/lib/api/types' or its corresponding type declarations.

Any reason this works in 8.15.1 but not in 8.17.0? Can we still import types or no?

Things tried

  • Using @types/elasticsearch, this works to bring in types, but that package is missing IndexRequest among other types and at least the SearchResponse type is incompatible with the official @elastic/elasticsearch exported API.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions