-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix const enum issues #1593
Fix const enum issues #1593
Conversation
… importing types in projects with tsconfig option isolateModules true (like Next.js)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for raising this PR @jonespen, and for your first contribution here! 🎉
bors merge
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 <jonespen@gmail.com>
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1593 +/- ##
==========================================
+ Coverage 97.42% 97.43% +0.01%
==========================================
Files 22 22
Lines 814 819 +5
Branches 109 109
==========================================
+ Hits 793 798 +5
Misses 20 20
Partials 1 1
☔ View full report in Codecov by Sentry. |
This PR was included in a batch that successfully built, but then failed to merge into main. It will not be retried. Additional information: {"message":"At least 1 approving review is required by reviewers with write access.","documentation_url":"https://docs.github.com/articles/about-protected-branches"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors merge
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 withisolatedModules: true
(like Next.js). Instead, regular objects can be used (like done in #1350) withas 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:
Thank you so much for contributing to Meilisearch!