Skip to content
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: include type cast on ts compilation #1962

Merged
merged 2 commits into from
Jun 20, 2024
Merged

Conversation

tagleeson
Copy link
Contributor

Description

In typescript projects which are using ts-reset and compileNamespace: "ts", the compiled output is invalid because the type of JSON.parse is changed to unknown from the normal any, meaning that you cannot just use a type annotation and must use an explicit cast. There doesn't seem to be any simple configuration that could fix this issue, so this PR with an explicit type cast seems to be a logical answer.

It doesn't affect anyone who is not using ts-reset, and expands compatibility for those who are.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

Copy link

vercel bot commented Jun 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2024 0:34am

Copy link

github-actions bot commented Jun 19, 2024

size-limit report 📦

Path Size
./packages/core/dist/index.mjs 2.88 KB (0%)
./packages/detect-locale/dist/index.mjs 723 B (0%)
./packages/react/dist/index.mjs 1.67 KB (0%)
./packages/remote-loader/dist/index.mjs 7.26 KB (0%)

@timofei-iatsenko
Copy link
Collaborator

So type of the const is not needed then:

- export const messages:Messages=JSON.parse();
+ export const messages=(JSON.parse()) as Messages;

@timofei-iatsenko timofei-iatsenko self-requested a review June 19, 2024 07:23
@tagleeson
Copy link
Contributor Author

@thekip I was trying to make as minimal of a change as possible, happy to remove the unnecessary annotation. Updated.

Copy link

codecov bot commented Jun 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.42%. Comparing base (d6b9698) to head (3be700b).
Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1962      +/-   ##
==========================================
- Coverage   76.65%   75.42%   -1.23%     
==========================================
  Files          81       85       +4     
  Lines        2090     2132      +42     
  Branches      533      545      +12     
==========================================
+ Hits         1602     1608       +6     
- Misses        375      411      +36     
  Partials      113      113              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andrii-bodnar andrii-bodnar merged commit 0f66617 into lingui:main Jun 20, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants