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: escape keys in generated types #143

Merged
merged 4 commits into from
Dec 16, 2024
Merged

fix: escape keys in generated types #143

merged 4 commits into from
Dec 16, 2024

Conversation

Morgbn
Copy link
Contributor

@Morgbn Morgbn commented Oct 21, 2024

escapeKey function was not checking for valid property names. For example, { "2ndKey" : "…" } was returning 2ndKey: string causing ts errors.
I originally encountered this error opening .nuxt/types/schema.d.ts containing tailwind config with 2xl, 3xl...
image
Hope this pull request help.

@Morgbn
Copy link
Contributor Author

Morgbn commented Dec 16, 2024

Hello, is there anything missing ?

@pi0 pi0 changed the title fix: escapeKey regex check valid property names fix: generate valid types for keys need escaping Dec 16, 2024
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks for PR and tests ❤️

I've refactored to use knitwork utils which is little bit safer

@pi0 pi0 changed the title fix: generate valid types for keys need escaping fix: escape keys in generated types Dec 16, 2024
@pi0 pi0 merged commit 776c59d into unjs:main Dec 16, 2024
2 checks passed
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.01%. Comparing base (71cb7e3) to head (e959739).
Report is 26 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #143      +/-   ##
==========================================
- Coverage   57.90%   51.01%   -6.90%     
==========================================
  Files          18       17       -1     
  Lines        1872     1631     -241     
  Branches      284      287       +3     
==========================================
- Hits         1084      832     -252     
- Misses        779      790      +11     
  Partials        9        9              

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

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