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

Fixes #36 | Allows for single value unions #37

Merged
merged 2 commits into from
Jul 29, 2021

Conversation

anglinb
Copy link
Contributor

@anglinb anglinb commented Jul 28, 2021

Why

Fixes #36. Handles single value unions how typescript handles them.

@anglinb anglinb changed the title anglinb/36 Fixes #36 | Allows for single value unions Jul 28, 2021
@fabien0102 fabien0102 self-requested a review July 29, 2021 09:14
@fabien0102 fabien0102 self-assigned this Jul 29, 2021
Copy link
Owner

@fabien0102 fabien0102 left a comment

Choose a reason for hiding this comment

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

Good catch! 🎉

@codecov-commenter
Copy link

Codecov Report

Merging #37 (e1751ca) into main (e5e4961) will decrease coverage by 0.44%.
The diff coverage is 96.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #37      +/-   ##
==========================================
- Coverage   98.49%   98.05%   -0.45%     
==========================================
  Files           8        9       +1     
  Lines         332      359      +27     
  Branches      102      108       +6     
==========================================
+ Hits          327      352      +25     
- Misses          5        6       +1     
- Partials        0        1       +1     
Impacted Files Coverage Δ
src/utils/resolveDefaultProperties.ts 95.23% <95.23%> (ø)
src/core/generateZodSchema.ts 97.29% <100.00%> (+0.09%) ⬆️
src/core/jsDocTags.ts 98.46% <100.00%> (-1.54%) ⬇️
src/core/validateGeneratedTypes.ts 97.43% <100.00%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6ae0a1...e1751ca. Read the comment docs.

@@ -168,6 +168,13 @@ describe("generateZodSchema", () => {
);
});

it("should generate a literal schema for a single union", () => {
const source = `export type Identity = | "superman";`;
Copy link
Owner

Choose a reason for hiding this comment

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

I was not even aware of this notation 😅 make totally sense!

Copy link
Contributor Author

@anglinb anglinb Jul 29, 2021

Choose a reason for hiding this comment

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

Haha ya I use it to remind myself this will be a union but haven't filled out everything yet. Typescript is pretty rad :P (And so is ts-to-zod, it's super useful!!)

@fabien0102 fabien0102 merged commit 9734548 into fabien0102:main Jul 29, 2021
fabien0102 pushed a commit that referenced this pull request Jul 29, 2021
* Checks in failing test documenting behavior

* Fixes test by checking for single value unions.
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.

Does not handle single value unions
3 participants