feat(cdk): improve RxStrategy typing and auto completion#1900
Open
ChristopherPHolder wants to merge 3 commits into
Open
feat(cdk): improve RxStrategy typing and auto completion#1900ChristopherPHolder wants to merge 3 commits into
ChristopherPHolder wants to merge 3 commits into
Conversation
Nx Cloud AI Fix could not be generatedView your CI Pipeline Execution ↗ for commit 3cf2695
☁️ Nx Cloud last updated this comment at |
Member
|
Thanks @ChristopherPHolder . We might need to consider this as a breaking change? |
Contributor
Author
@hoebbelsB Seems like a breaking change, especially considering the build that fails now.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
This MR improves the typing of the RxStrategyProvider by changing the type generics default parameter to the real default
Motivation
Allow for better auto-completion and type correctness as well as preventing typos.
Cases
1. Injected in constructor without generic
Before
After
2. Injected in constructor with generic
There is not behavior change here.
3. Injected with inject without generic
There is not behavior change here.
4. Injected with inject with generic
Before
After
Notes
It's important to consider the trade-off here; adding the real defaults will prevent typos but will force you to pass generics when you create custom strategies.
It's a question of if the user should have a default narrow type or wide type.
To me, this seems like a reasonable choice, especially since the use of custom strategies is very advanced, so the requirement of passing an additional generic to widen the type seems reasonable, as it's only for that "niche" case.
Additionally, due to the current issue with the typing of the inject function without passing a generic, it would also be reasonable to expo a wrapping function mainly used to fix the generic typing, but that seems to be passing any.
But to be honest, I have not investigated further as to why this is happening.