-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
Extra Operator Generics in Typescript 2.4 #202
Comments
Hi @WorldMaker.
function dropRepeats<T>(
isEqual: ((x: T, y: T) => boolean) | undefined = void 0
): (ins: Stream<T>) => Stream<T> {
return function dropRepeatsOperator<T>(ins: Stream<T>): Stream<T> {
return new Stream<T>(new DropRepeatsOperator<T>(ins, isEqual));
};
}
Thanks for reporting. |
Ignore what I just said, I was missing a detail function dropRepeats<T>(
isEqual: ((x: T, y: T) => boolean) | undefined = void 0
): (ins: Stream<T>) => Stream<T> {
- return function dropRepeatsOperator<T>(ins: Stream<T>): Stream<T> {
+ return function dropRepeatsOperator(ins: Stream<T>): Stream<T> {
return new Stream<T>(new DropRepeatsOperator<T>(ins, isEqual));
};
} So yeah, we need to do this:
|
Move the generic parameters of the extra operators to support better generic parameter inferencing in Typescript 2.4 while continuing to pass tests in Typescript 2.1. Delay is the only extra operator of this form skipped in this commit because it is the only one that didn't pass Typescript inferencing compile (in imitate tests) in Typescript 2.1 (though it builds in Typescript 2.4). Resolves staltz#202
Move the generic parameters of the extra operators to support better generic parameter inferencing in Typescript 2.4 while continuing to pass tests in Typescript 2.1. Delay is the only extra operator of this form skipped in this commit because it is the only one that didn't pass Typescript inferencing compile (in imitate tests) in Typescript 2.1 (though it builds in Typescript 2.4). Resolves #202
Move the generic parameters of the extra operators to support better generic parameter inferencing in Typescript 2.4 while continuing to pass tests in Typescript 2.1. Delay is the only extra operator of this form skipped in this commit because it is the only one that didn't pass Typescript inferencing compile (in imitate tests) in Typescript 2.1 (though it builds in Typescript 2.4). Resolves #202
PR #206 was merged to branch |
Move the generic parameters of the extra operators to support better generic parameter inferencing in Typescript 2.4 while continuing to pass tests in Typescript 2.1. Delay is the only extra operator of this form skipped in this commit because it is the only one that didn't pass Typescript inferencing compile (in imitate tests) in Typescript 2.1 (though it builds in Typescript 2.4). Resolves #202
Typescript 2.4 has better generic type inference, including better support for unifying return types in generic functions with the generic type parameter. I'm getting type inferencing issues in Typescript 2.4 that I can't seem to solve (x is not x errors) trying to use some of the extra operators and I think it's because of the way the generics are used in the library.
Take the signature for
dropRepeats
for example:In Typescript 2.4 I'm getting an error because the generic parameter
T
for theisEqual
is not the generic parameterT
for the return function. That's not something that Typescript prior to 2.4 has checked.It seems to me that the obvious solution to move the generic parameter to the outer function would both fix this problem for Typescript 2.4 and happen to give better type inferencing in Typescript before 2.4:
This updated version of the operator function passes all the existing tests in Typescript 2.1 (current package.json version). The tests don't currently run in Typescript 2.4; seems like there are updates need to be made to the mocha and other types first.
I'm happy to make a PR to move the generics in the extra operators to this simpler form, but I wanted to make sure I wasn't missing some reason for why the generics were written the way they were originally.
The text was updated successfully, but these errors were encountered: