-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[typescript] Avoid code duplication #20978
base: master
Are you sure you want to change the base?
[typescript] Avoid code duplication #20978
Conversation
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.
The diff is hard to check - can we revert the whitespace only and quote changes?
Also, regarding the changed default behavior, did you revert that to the behavior before the change in this pull request or did you just mention it for a follow up? I think we should probably restore it to what it was, and involve the original author and @macjohnny when doing so.
Possibly two PRs, one clean refactor and one restore ot the previous behavior might be good. Don't mind the order.
this significantly cleans up the logic.
this was done to preserve backward compatibility with the previous pattern in which the entire the default use of the 'replace' middlewareMergeStrategy really only makes sense for middelware values that are arrays, so I'd be in favor of this change to the default behavior. to be clear, the change is the following: {middleware: undefined } // preserves existing middleware
{middleware: []} // replaces existing middleware with empty array, same as
{middleware: [], middlewareMergeStrategy: 'replace'} // same as above since default middlewareMergeStrategy is 'replace' this would benefit greatly from adding tests to cover both cases here's where i put the current tests |
You are absolutely right, @joscha. I probably crammed in to much into a single commit in the flow of things. @davidgamero Thanks for your support :-) Adding tests is definitely a good idea. |
bdfe45c
to
e085d8e
Compare
Ok, I now made smaller commits, @joscha . I hope this works for you. Btw (you probably know this), but there is an option in github to hide whitespace changes. I'll cerate a separate PR for more refactoring and the behaviour change when options are given, but without a middleware field. |
In #20430 a lot of new code was added in the output. Most of it can be avoided by reusing central functions.
These changed should not change the functionality.
There is however one minor detail that is different now: If
_options
is given, but without any middleware, the existing middleware is kept. To clear it{ middleware: [] }
needs to be passed. I think the previous behaviour was an oversight, becacuse all other items fall back properly as well.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)CC @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) @joscha (2024/10)