fix: reorder overloads so typescript doesn't prefer deprecations #5996
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 is mostly a reordering of overloads, which moves deprecated overloads to the bottom, which in turn makes TS evaluate them last and solves most "false-positives" for usages of deprecated overloads.
As a bonus, this PR also solves inability of
pipe
and some other functions to accept unrestricted amounts of arguments, while maintaining the type integrity.As a cost for this, however, the
pipe
function does not explicitly error on incorrect operator type chains and simply defaults toObservable<unknown>
.All current unit tests pass.
However, some tests actively use deprecated functions, and I don't know if its intentional or not, so I didn't take the courage of rewriting those (specifically, the
forkJoin
ones that use deprecated "...spread" overloads) and adjusted overloads accordingly.Related issue (if exists):
fixes #5064, fixes #5966, fixes #5557, fixes #4177, fixes #3989, and many, many more.
Most discussions in related issues have become stale or full of workarounds instead of solutions, so this PR aims to resolve a bunch of them at once.