Typescript: @fastify/elasticsearch does not accept older client
- Dominant language
- No language data
- Stars
- 68
- Forks
- 8
- Avg merge
- 11h 2m
- Merged PRs (30d)
- 2
Description
Hi Team,
I need to use a previous version of the client while registering the fastifyelasticsearch in typescript.
I am doing it like this
```ts
import fp from 'fastify-plugin';
import fastifyElasticsearch from '@fastify/elasticsearch';
import { Client } from '@elastic/elasticsearch';
export default fp(async (server) => {
try {
await server.register(fastifyElasticsearch, {
client: new Client({ node: 'http://localhost:9200' }),
});
} catch (error) {
server.log.error(error, 'Failed to initialize Elasticsearch');
throw error;
}
});
````
But it is giving me an error for the new Client :
```js
No overload matches this call.
Overload 1 of 3, '(plugin: FastifyPluginCallback, opts?: FastifyRegisterOptions<...>): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Type 'Client' is missing the following properties from type 'Client': diagnostic, name, helpers, asyncSearch, and 72 more.
Overload 2 of 3, '(plugin: FastifyPluginAsync, opts?: FastifyRegisterOptions<...>): FastifyInstance<...> & PromiseLike<...>', gave the following error.Overload 2 of 3, '(plugin: FastifyPluginAsync, opts?: FastifyRegisterOptions<...>): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Type 'import("/node_modules/@elastic/elasticsearch/index").Client' is not assignable to type 'import("/node_modules/@fastify/elasticsearch/node_modules/@elastic/elasticsearch/lib/client").default'.
Overload 3 of 3, '(plugin: FastifyPluginAsync | FastifyPluginCallback<...> | Promise<...> | Promise<...>, opts?: FastifyRegisterOptions<...>): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Type 'import("/node_modules/@elastic/elasticsearch/index").Client' is not assignable to type 'import("/node_modules/@fastify/elasticsearch/node_modules/@elastic/elasticsearch/lib/client").default'.ts(2769)
````
Can you help here to solve this issue?
## Your Environment
- *node version*: v18.15.0
- *fastify version*: >=2.0.0
- "@elastic/elasticsearch": "^5.6.22",
- "@fastify/elasticsearch": "^3.1.0",
- *os*: Mac
Contributor guide
Assessment
This issue has not been assessed yet.