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: expression only choices / select options #1523

Merged
merged 2 commits into from
Mar 16, 2023

Conversation

taozhou-glean
Copy link
Contributor

@taozhou-glean taozhou-glean commented Mar 16, 2023

Description

to fix #1522

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

Fixes # (issue) #1522

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 necessary documentation (if appropriate)

@vercel
Copy link

vercel bot commented Mar 16, 2023

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

Name Status Preview Comments Updated
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 16, 2023 at 3:26PM (UTC)

@taozhou-glean taozhou-glean marked this pull request as ready for review March 16, 2023 03:25
@github-actions
Copy link

github-actions bot commented Mar 16, 2023

size-limit report 📦

Path Size
./packages/core/build/esm/index.js 1.57 KB (0%)
./packages/detect-locale/build/esm/index.js 812 B (0%)
./packages/react/build/esm/index.js 1.67 KB (0%)
./packages/remote-loader/build/esm/index.js 7.25 KB (0%)

@@ -352,8 +352,12 @@ export default class MacroJs {
value = this.tokenizeTemplateLiteral(attrValue)
} else if (this.types.isCallExpression(attrValue)) {
value = this.tokenizeNode(attrValue)
} else if (this.types.isStringLiteral(attrValue)) {
value = attrValue.value
} else if (this.types.isExpression(attrValue)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringLiteral is also considered as Expression, so I moved StringLiteral check above. From ts, after all the checks, the types fall through are limited to babelTypes.RestElement | babelTypes.AssignmentPattern | babelTypes.ArrayPattern | babelTypes.ObjectPattern, not sure exactly how we want to handle them, so I kept the previous fallback case untouched.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the unknown conversion is just to make ts happy, please let me know if you have other suggestions to handle the remaining cases.

@taozhou-glean taozhou-glean changed the title fix: expression only cases fix: expression only choices / select options Mar 16, 2023
@codecov
Copy link

codecov bot commented Mar 16, 2023

Codecov Report

Patch coverage: 60.00% and project coverage change: +1.15 🎉

Comparison is base (7fc9dee) 74.55% compared to head (d39ca42) 75.70%.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1523      +/-   ##
==========================================
+ Coverage   74.55%   75.70%   +1.15%     
==========================================
  Files          76       79       +3     
  Lines        1965     1984      +19     
  Branches      515      518       +3     
==========================================
+ Hits         1465     1502      +37     
+ Misses        389      361      -28     
- Partials      111      121      +10     
Impacted Files Coverage Δ
packages/macro/test/js-plural.ts 100.00% <ø> (ø)
packages/macro/test/js-select.ts 100.00% <ø> (ø)
packages/macro/test/jsx-plural.ts 100.00% <ø> (ø)
packages/macro/test/jsx-select.ts 100.00% <ø> (ø)
packages/macro/src/macroJs.ts 95.45% <60.00%> (-1.22%) ⬇️

... and 18 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@timofei-iatsenko timofei-iatsenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the same is true for JSX and components. Could you also check add that? And it also should be checked for SWC Plugin. I think it should work already but at least the same test cases should be added to have test suite aligned.

packages/macro/src/macroJs.test.ts Outdated Show resolved Hide resolved
@andrii-bodnar andrii-bodnar linked an issue Mar 16, 2023 that may be closed by this pull request
@taozhou-glean
Copy link
Contributor Author

I think the same is true for JSX and components. Could you also check add that? And it also should be checked for SWC Plugin. I think it should work already but at least the same test cases should be added to have test suite aligned.

macroJsx's fallback is to tokenizeExpression, so it does not have the same issue with the js macros, added a few tests there as well.

@taozhou-glean
Copy link
Contributor Author

taozhou-glean commented Mar 16, 2023

swc-plugin change in lingui/swc-plugin#40

is there a guide how to run tests etc ? I have zero experience with rust before... I can read more about it but would be great if there is a command that I can just copy and paste to run the tests ;)

edited: nvm, found that i can just install cargo and run cargo test

@andrii-bodnar andrii-bodnar merged commit db6e497 into lingui:next Mar 16, 2023
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.

variable only cases in select is omitted
3 participants