Skip to content

feat: support logical and member expression#111

Merged
antfu merged 1 commit intomainfrom
feat/support-logical-and-member-expression
Apr 12, 2024
Merged

feat: support logical and member expression#111
antfu merged 1 commit intomainfrom
feat/support-logical-and-member-expression

Conversation

@lihbr
Copy link
Member

@lihbr lihbr commented Apr 10, 2024

🔗 Linked issue

N/A

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This PR adds support for logical and member expression, allowing for that kind of code modification with builder.raw() (which would have thrown a MagicastError before)

+ import { foo, bar } as config from "./config.json";

  export const a = {
+   bar: config.foo || config.bar
  }

I'm by far not an AST expert so I'm not sure if my changes cover it all. Also I'm not sure if this kind of node support is welcome/within the scope of Magicast, so let me know if not, no big deal ☺️

On another note, I feel like there's a pattern here, maybe we want to support other node types like conditional expressions (foo ? bar : baz) with some kind of generic proxy instead for "readonly" kind of node. Feel free to nudge me towards the direction that fits better the project!

Thanks!

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

Attention: Patch coverage is 93.10345% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 93.53%. Comparing base (46f6cee) to head (79dfb20).

Files Patch % Lines
src/proxy/logical-expression.ts 89.47% 2 Missing ⚠️
src/proxy/member-expression.ts 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
- Coverage   93.54%   93.53%   -0.02%     
==========================================
  Files          25       27       +2     
  Lines        1797     1855      +58     
  Branches      335      341       +6     
==========================================
+ Hits         1681     1735      +54     
- Misses        115      119       +4     
  Partials        1        1              

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

@antfu antfu merged commit c76c5ac into main Apr 12, 2024
@lihbr lihbr deleted the feat/support-logical-and-member-expression branch April 12, 2024 08:28
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.

2 participants