fix(pipe): replace rest parameters overload#3945
Merged
benlesh merged 15 commits intoReactiveX:masterfrom Jul 26, 2018
Merged
Conversation
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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:
IMPORTANT: This PR depends upon the dtslint additions in #3944.WARNING: This PR uncovered several typing problems in the test suite, so it's likely that it will also uncover typing problems in user code that were previously hidden. Said problems in the test suite could have been hidden for a number of reasons:
It fixes a problem that was introduced in this commit. Prior to that commit, the
pipeoverload signature for more than 9 arguments looked like this:Which is incorrect, as consecutive arguments have to have matching output/input types - every
OperatorFunctionpassed cannot accept aTand return anR.Unfortunately, fixing that by changing the signature to the following introduced another problem:
With that signature, any usage with 9 or fewer arguments that does not match a signature due to type errors will now match the rest parameters signature. So strong typing is subverted and that's the problem highlighted in #3841.
In a comment in this TypeScript issue, Anders Hejlsberg has pointed out the output/input relationship between arguments means that the overloads cannot be avoided. So to restore strong typing, this PR replaces the rest parameters overload signature with a signature that also includes the preceding 9 type-parameter-specified arguments, like this:
The effect of this is that it will no longer be possible to specify a single
Rtype parameter forpipecalls that involve more than 9 arguments. Instead, an assertion would need to be used like this:This PR also adds dtslint tests for
pipeand the staticpipeutility function that include expectations for type inference and errors.Related issue (if exists): #3841