-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add import handling for external classes #135
Add import handling for external classes #135
Conversation
45ae5ec
to
a6bf5e4
Compare
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #135 +/- ##
==========================================
+ Coverage 96.90% 97.05% +0.15%
==========================================
Files 14 15 +1
Lines 742 782 +40
Branches 309 316 +7
==========================================
+ Hits 719 759 +40
Misses 23 23 ☔ View full report in Codecov by Sentry. |
a6bf5e4
to
e8fb69f
Compare
e8fb69f
to
980a243
Compare
Blocked by #140 |
aeacdec
to
1454715
Compare
Hey @fabien0102, Thank you for your recent update & merge. I acknowledge that this feature is a bit opinionated as it takes any non-relative import as not being a zod schema. As a follow-up, I see an opening to handle relative imports as zod schemas (generated or not) and may open up the door to multi-file generation support eventually. |
Thanks for the PR!
I think this is a sensible default. One option came to my mind: Use a comment to tell ts-to-zod that the import is assumed to be a zod schema. // source.ts
import { Person } from "@3rdparty/person";
// ts-to-zod ImportIsZodSchema Person
export interface Hero {
name: string;
realPerson: Person;
} Its semantics would be:
I don't understand the reasoning, could you explain/clarify in your OP? :) |
The rationale behind using only non-relative imports for this feature was mostly based on the rationale that 3rd party imports had very little chance to be Zod Schema. Relative imports, on the other hand, have maybe a higher chance to be a class / type / interface that is also transformed somewhere in the codebase into a zodSchema. 👉 In the meantime, it's quite easy to handle any imports as 3rd party ones and have specific JSTags comments in the future to handle zod schema (generated or referenced manually) |
Hello @dan-blank, @fabien0102 👋 I updated this PR to allow any type of imports (non-relative and relative modules alltogether). WDYT? |
Looks good here as well! Ran into the same small issue mentioned in your other PR. |
a9c771f
to
66162cd
Compare
66162cd
to
ad53baa
Compare
22733f8
to
ae84ac4
Compare
Hello @fabien0102 , @schiller-manuel After much discussions and thoughts, I reworked this Pull Request to support It was previously using Additionally, I had to update the But now this supports simply the imports, and I will rebase #148 to support imports of Zod Schemas as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, would love to get this and #148 merged asap.
can you clean this up (see my comments) please?
Hey @schiller-manuel, Thank you for you review, I just cleaned the two commented lines. Thanks. |
Why
This PR adds support for imports.
The following input:
will output