Skip to content

Commit

Permalink
Merge #1593
Browse files Browse the repository at this point in the history
1593: Fix const enum issues r=brunoocasali a=jonespen

# Pull Request

## Related issue
Fixes #1588

## What does this PR do?
`const enum` is not really suited for libraries (ref https://youtu.be/jjMbPt_H3RQ?feature=shared&t=249 and https://www.typescriptlang.org/docs/handbook/enums.html#const-enum-pitfalls) and cause issues in typescript projects with `isolatedModules: true` (like Next.js). Instead, regular objects can be used (like done in #1350) with `as const` to make them type safe. 

About the `as readonly string[]` in cfcda4f, this could probably have been solved by a type guard as well, but I opted for the type cast option instead to avoid runtime code changes. 

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: Jon Espen Kvisler <[email protected]>
  • Loading branch information
meili-bors[bot] and jonespen authored Oct 17, 2023
2 parents 8a74e35 + cfcda4f commit 8fea5e4
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 139 deletions.
7 changes: 4 additions & 3 deletions src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ class TaskClient {
while (Date.now() - startingTime < timeOutMs) {
const response = await this.getTask(taskUid)
if (
![TaskStatus.TASK_ENQUEUED, TaskStatus.TASK_PROCESSING].includes(
response.status
)
!([
TaskStatus.TASK_ENQUEUED,
TaskStatus.TASK_PROCESSING,
] as readonly string[]).includes(response.status)
)
return response
await sleep(intervalMs)
Expand Down
Loading

0 comments on commit 8fea5e4

Please sign in to comment.