-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: siblings in parser-zod for better AST manipulation #1342
feat: siblings in parser-zod for better AST manipulation #1342
Conversation
🦋 Changeset detectedLatest commit: 6071f37 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
b611eca
to
bf4173e
Compare
@@ -171,7 +171,7 @@ type ParserOptions = { | |||
coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean } | |||
} | |||
|
|||
export function parse(parent: Schema | undefined, current: Schema, options: ParserOptions): string | undefined { | |||
export function parse(parent: Schema | undefined, current: Schema, options: ParserOptions, siblings: Schema[]): string | undefined { |
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.
we can probably refactor this as follow:
(not sure about the name ParserAst
)
type ParserAst= {
parent: Schema | undefined,
current: Schema
siblings: Schema[]
}
export function parse({ current, parent, siblings } : ParserAst , options: ParserOptions): string | undefined {
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.
I've given it a go, in the newest version here
bf4173e
to
60478fe
Compare
@stijnvanhulle I've made the refactor in this 😊 Feel free to either merge this or #1341 depending on your preference. The other should be closed afterwards 👌 |
@ChilloManiac This looks better, I would prefer this kind of structure for the parser. We only need to move this to the other parsers(zod, ts and faker plugin) so we have the same way of getting siblings and the parent(like you have done here). |
@stijnvanhulle will you do those changes? And will it be a part of this PR? |
@ChilloManiac You can already merge this one and then when I find some time this or next week I can also do the same for the other plugins that uses parsers. |
Sorry, but only those with write access to your repo can merge it, even if its approved 😅 |
This is an alternative to #1341 and #1292
I like this implementation better, but it might differ from the "usual" way plugins are structured in @kubb atm