meilisearch / meilisearch-js

JavaScript client for the Meilisearch API

Home Page:https://www.meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I import the EnqueuedTask class?

wancup opened this issue · comments

On v0.29.0, EnqueuedTask class is not exported from meilisearch-js package.

import type { EnqueuedTask } from "meilisearch";

↓

$ tsc
TS2614: Module '"meilisearch"' has no exported member 'EnqueuedTask'. Did you mean to use 'import EnqueuedTask from "meilisearch"' instead?

Currently(v 0.28.0), I import and use the EnqueuedTask type in my modules. So, this change is a bit inconvenient.
There is a plan to export EnqueuedTask class? Or should I not reuse the class in my files?

Hey @wancup enqueuedTask is now a Class you can import it without the type wording.

Or, alternatively, you can use enqueuedTaskObject in case you are not using the class but the object

See #1343

@bidoubiwa Thanks for the reply!
And sorry, my example was wrong. But, without the type word, I get the same result.

スクリーンショット 2022-11-02 23 09 59

https://codesandbox.io/s/staging-dust-7e1x97?file=/src/index.ts

I think the reason why is EnqueuedTask class (in enqueued-task.ts) is not exported in src/index.ts.
https://github.com/meilisearch/meilisearch-js/blob/main/src/index.ts

Because I wrap some sdk methods in my modules, I want to return the same type of sdk's return values. So I want to use EnqueuedTask class instead of EnqueuedTaskObject.
Like;

import { EnqueuedTask } from "meilisearch";

export async function deleteX(): Promise<EnqueuedTask> {
  return client.index("xxx").deleteDocument("id");
}

Am I still misunderstanding something?

Hey @wancup, my bad you are right! Fixing this asap :) #1377

Fixed and released in v0.29.1.

Could you confirm it fixes your issue?

It's fixed! Thank you so much! @bidoubiwa